v0.7.4b: refactored input event handling structure
This commit is contained in:
@@ -27,8 +27,6 @@ import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.WelcomeScene;
|
||||
import com.watabou.noosa.Game;
|
||||
|
||||
-1
@@ -22,7 +22,6 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.CorrosiveGas;
|
||||
|
||||
@@ -37,8 +37,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ImpShopRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.input.Touchscreen.Touch;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.RenderedText;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.utils.DeviceCompat;
|
||||
|
||||
public class AboutScene extends PixelScene {
|
||||
@@ -92,9 +92,9 @@ public class AboutScene extends PixelScene {
|
||||
shpxlink.setPos((colWidth - shpxlink.width()) / 2, shpxtext.bottom() + 6);
|
||||
align(shpxlink);
|
||||
|
||||
TouchArea shpxhotArea = new TouchArea( shpxlink.left(), shpxlink.top(), shpxlink.width(), shpxlink.height() ) {
|
||||
PointerArea shpxhotArea = new PointerArea( shpxlink.left(), shpxlink.top(), shpxlink.width(), shpxlink.height() ) {
|
||||
@Override
|
||||
protected void onClick( Touch touch ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
DeviceCompat.openURI( "https://" + LNK_SHPX );
|
||||
}
|
||||
};
|
||||
@@ -133,9 +133,9 @@ public class AboutScene extends PixelScene {
|
||||
wataLink.setPos(wataOffset + (colWidth - wataLink.width()) / 2 , wataText.bottom() + 6);
|
||||
align(wataLink);
|
||||
|
||||
TouchArea hotArea = new TouchArea( wataLink.left(), wataLink.top(), wataLink.width(), wataLink.height() ) {
|
||||
PointerArea hotArea = new PointerArea( wataLink.left(), wataLink.top(), wataLink.width(), wataLink.height() ) {
|
||||
@Override
|
||||
protected void onClick( Touch touch ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
DeviceCompat.openURI( "https://" + LNK_WATA );
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -499,12 +499,12 @@ public class AlchemyScene extends PixelScene {
|
||||
|
||||
slot = new ItemSlot() {
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
bg.brightness( 1.2f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
};
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
bg.resetColor();
|
||||
}
|
||||
@Override
|
||||
|
||||
+27
-27
@@ -28,13 +28,13 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
||||
import com.watabou.input.Touchscreen.Touch;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.utils.GameMath;
|
||||
import com.watabou.utils.PointF;
|
||||
|
||||
public class CellSelector extends TouchArea {
|
||||
public class CellSelector extends PointerArea {
|
||||
|
||||
public Listener listener = null;
|
||||
|
||||
@@ -50,14 +50,14 @@ public class CellSelector extends TouchArea {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick( Touch touch ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
if (dragging) {
|
||||
|
||||
dragging = false;
|
||||
|
||||
} else {
|
||||
|
||||
PointF p = Camera.main.screenToCamera( (int)touch.current.x, (int)touch.current.y );
|
||||
PointF p = Camera.main.screenToCamera( (int) event.current.x, (int) event.current.y );
|
||||
for (Char mob : Dungeon.level.mobs.toArray(new Mob[0])){
|
||||
if (mob.sprite != null && mob.sprite.overlapsPoint( p.x, p.y)){
|
||||
select( mob.pos );
|
||||
@@ -73,8 +73,8 @@ public class CellSelector extends TouchArea {
|
||||
}
|
||||
|
||||
select( ((DungeonTilemap)target).screenToTile(
|
||||
(int)touch.current.x,
|
||||
(int)touch.current.y,
|
||||
(int) event.current.x,
|
||||
(int) event.current.y,
|
||||
true ) );
|
||||
}
|
||||
}
|
||||
@@ -111,47 +111,47 @@ public class CellSelector extends TouchArea {
|
||||
}
|
||||
|
||||
private boolean pinching = false;
|
||||
private Touch another;
|
||||
private PointerEvent another;
|
||||
private float startZoom;
|
||||
private float startSpan;
|
||||
|
||||
@Override
|
||||
protected void onTouchDown( Touch t ) {
|
||||
protected void onPointerDown( PointerEvent event ) {
|
||||
|
||||
if (t != touch && another == null) {
|
||||
if (event != curEvent && another == null) {
|
||||
|
||||
if (!touch.down) {
|
||||
touch = t;
|
||||
onTouchDown( t );
|
||||
if (!curEvent.down) {
|
||||
curEvent = event;
|
||||
onPointerDown( event );
|
||||
return;
|
||||
}
|
||||
|
||||
pinching = true;
|
||||
|
||||
another = t;
|
||||
startSpan = PointF.distance( touch.current, another.current );
|
||||
another = event;
|
||||
startSpan = PointF.distance( curEvent.current, another.current );
|
||||
startZoom = camera.zoom;
|
||||
|
||||
dragging = false;
|
||||
} else if (t != touch) {
|
||||
} else if (event != curEvent) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp( Touch t ) {
|
||||
if (pinching && (t == touch || t == another)) {
|
||||
protected void onPointerUp( PointerEvent event ) {
|
||||
if (pinching && (event == curEvent || event == another)) {
|
||||
|
||||
pinching = false;
|
||||
|
||||
zoom(Math.round( camera.zoom ));
|
||||
|
||||
dragging = true;
|
||||
if (t == touch) {
|
||||
touch = another;
|
||||
if (event == curEvent) {
|
||||
curEvent = another;
|
||||
}
|
||||
another = null;
|
||||
lastPos.set( touch.current );
|
||||
lastPos.set( curEvent.current );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,13 +159,13 @@ public class CellSelector extends TouchArea {
|
||||
private PointF lastPos = new PointF();
|
||||
|
||||
@Override
|
||||
protected void onDrag( Touch t ) {
|
||||
protected void onDrag( PointerEvent event ) {
|
||||
|
||||
camera.target = null;
|
||||
|
||||
if (pinching) {
|
||||
|
||||
float curSpan = PointF.distance( touch.current, another.current );
|
||||
float curSpan = PointF.distance( curEvent.current, another.current );
|
||||
float zoom = (startZoom * curSpan / startSpan);
|
||||
camera.zoom( GameMath.gate(
|
||||
PixelScene.minZoom,
|
||||
@@ -174,14 +174,14 @@ public class CellSelector extends TouchArea {
|
||||
|
||||
} else {
|
||||
|
||||
if (!dragging && PointF.distance( t.current, t.start ) > dragThreshold) {
|
||||
if (!dragging && PointF.distance( event.current, event.start ) > dragThreshold) {
|
||||
|
||||
dragging = true;
|
||||
lastPos.set( t.current );
|
||||
lastPos.set( event.current );
|
||||
|
||||
} else if (dragging) {
|
||||
camera.scroll.offset( PointF.diff( lastPos, t.current ).invScale( camera.zoom ) );
|
||||
lastPos.set( t.current );
|
||||
camera.scroll.offset( PointF.diff( lastPos, event.current ).invScale( camera.zoom ) );
|
||||
lastPos.set( event.current );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.glwrap.Blending;
|
||||
import com.watabou.input.Touchscreen;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.BitmapText.Font;
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
@@ -164,7 +164,7 @@ public class PixelScene extends Scene {
|
||||
@Override
|
||||
public void destroy() {
|
||||
super.destroy();
|
||||
Touchscreen.event.removeAll();
|
||||
PointerEvent.clearListeners();
|
||||
}
|
||||
|
||||
public static BitmapText.Font font;
|
||||
|
||||
+4
-4
@@ -41,7 +41,7 @@ import com.watabou.gltextures.SmartTexture;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.glwrap.Matrix;
|
||||
import com.watabou.glwrap.Quad;
|
||||
import com.watabou.input.Touchscreen.Touch;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.Game;
|
||||
@@ -49,7 +49,7 @@ import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NoosaScript;
|
||||
import com.watabou.noosa.TextureFilm;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.Visual;
|
||||
import com.watabou.noosa.audio.Music;
|
||||
import com.watabou.utils.Point;
|
||||
@@ -199,8 +199,8 @@ public class SurfaceScene extends PixelScene {
|
||||
window.add( a );
|
||||
window.add( pet );
|
||||
|
||||
window.add( new TouchArea( sky ) {
|
||||
protected void onClick( Touch touch ) {
|
||||
window.add( new PointerArea( sky ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
pet.jump();
|
||||
}
|
||||
} );
|
||||
|
||||
@@ -57,13 +57,13 @@ public class ExitButton extends Button {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
image.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
image.resetColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onSignal( String text ) {
|
||||
public synchronized boolean onSignal( String text ) {
|
||||
|
||||
if (length != entries.size()){
|
||||
clear();
|
||||
@@ -126,6 +126,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
||||
}
|
||||
|
||||
layout();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,13 +52,13 @@ public class IconButton extends Button {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
if (icon != null) icon.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
if (icon != null) icon.resetColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -83,13 +83,13 @@ public class LanguageButton extends Button {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
image.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
image.resetColor();
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
@@ -23,18 +23,18 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.input.Touchscreen;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.RenderedText;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.GameMath;
|
||||
import com.watabou.utils.PointF;
|
||||
|
||||
public abstract class OptionSlider extends Component {
|
||||
|
||||
private TouchArea touchArea;
|
||||
private PointerArea pointerArea;
|
||||
|
||||
private RenderedText title;
|
||||
private RenderedText minTxt;
|
||||
@@ -102,32 +102,24 @@ public abstract class OptionSlider extends Component {
|
||||
sliderNode = Chrome.get(Chrome.Type.RED_BUTTON);
|
||||
sliderNode.size(5, 9);
|
||||
|
||||
touchArea = new TouchArea(0, 0, 0, 0){
|
||||
pointerArea = new PointerArea(0, 0, 0, 0){
|
||||
boolean pressed = false;
|
||||
|
||||
@Override
|
||||
protected void onTouchDown(Touchscreen.Touch touch) {
|
||||
protected void onPointerDown( PointerEvent event ) {
|
||||
pressed = true;
|
||||
PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
|
||||
PointF p = camera().screenToCamera((int) event.current.x, (int) event.current.y);
|
||||
sliderNode.x = GameMath.gate(sliderBG.x-2, p.x, sliderBG.x+sliderBG.width()-2);
|
||||
sliderNode.brightness(1.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDrag(Touchscreen.Touch touch) {
|
||||
protected void onPointerUp( PointerEvent event ) {
|
||||
if (pressed) {
|
||||
PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
|
||||
sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp(Touchscreen.Touch touch) {
|
||||
if (pressed) {
|
||||
PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y);
|
||||
PointF p = camera().screenToCamera((int) event.current.x, (int) event.current.y);
|
||||
sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
|
||||
sliderNode.resetColor();
|
||||
|
||||
|
||||
//sets the selected value
|
||||
selectedVal = minVal + Math.round(sliderNode.x / tickDist);
|
||||
sliderNode.x = (int) (x + tickDist * (selectedVal - minVal));
|
||||
@@ -135,8 +127,16 @@ public abstract class OptionSlider extends Component {
|
||||
pressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDrag( PointerEvent event ) {
|
||||
if (pressed) {
|
||||
PointF p = camera().screenToCamera((int) event.current.x, (int) event.current.y);
|
||||
sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2);
|
||||
}
|
||||
}
|
||||
};
|
||||
add(touchArea);
|
||||
add(pointerArea);
|
||||
|
||||
}
|
||||
|
||||
@@ -162,10 +162,10 @@ public abstract class OptionSlider extends Component {
|
||||
sliderNode.x = (int)(x + tickDist*(selectedVal-minVal));
|
||||
sliderNode.y = sliderBG.y-4;
|
||||
|
||||
touchArea.x = x;
|
||||
touchArea.y = y;
|
||||
touchArea.width = width();
|
||||
touchArea.height = height();
|
||||
pointerArea.x = x;
|
||||
pointerArea.y = y;
|
||||
pointerArea.width = width();
|
||||
pointerArea.height = height();
|
||||
|
||||
BG.size(width(), height());
|
||||
BG.x = x;
|
||||
|
||||
@@ -50,13 +50,13 @@ public class PrefsButton extends Button {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
image.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
image.resetColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -97,11 +97,11 @@ public class QuickSlotButton extends Button implements WndBag.Listener {
|
||||
return QuickSlotButton.this.onLongClick();
|
||||
}
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
icon.lightness( 0.7f );
|
||||
}
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
icon.resetColor();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.input.Touchscreen.Touch;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.PointF;
|
||||
@@ -35,7 +35,7 @@ public class ScrollPane extends Component {
|
||||
protected static final int THUMB_COLOR = 0xFF7b8073;
|
||||
protected static final float THUMB_ALPHA = 0.5f;
|
||||
|
||||
protected TouchController controller;
|
||||
protected PointerController controller;
|
||||
protected Component content;
|
||||
protected ColorBlock thumb;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ScrollPane extends Component {
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
controller = new TouchController();
|
||||
controller = new PointerController();
|
||||
add( controller );
|
||||
|
||||
thumb = new ColorBlock( 1, 1, THUMB_COLOR );
|
||||
@@ -107,17 +107,17 @@ public class ScrollPane extends Component {
|
||||
public void onClick( float x, float y ) {
|
||||
}
|
||||
|
||||
public class TouchController extends TouchArea {
|
||||
public class PointerController extends PointerArea {
|
||||
|
||||
private float dragThreshold;
|
||||
|
||||
public TouchController() {
|
||||
public PointerController() {
|
||||
super( 0, 0, 0, 0 );
|
||||
dragThreshold = PixelScene.defaultZoom * 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp( Touch touch ) {
|
||||
protected void onPointerUp( PointerEvent event ) {
|
||||
if (dragging) {
|
||||
|
||||
dragging = false;
|
||||
@@ -125,7 +125,7 @@ public class ScrollPane extends Component {
|
||||
|
||||
} else {
|
||||
|
||||
PointF p = content.camera.screenToCamera( (int)touch.current.x, (int)touch.current.y );
|
||||
PointF p = content.camera.screenToCamera( (int) event.current.x, (int) event.current.y );
|
||||
ScrollPane.this.onClick( p.x, p.y );
|
||||
|
||||
}
|
||||
@@ -135,12 +135,12 @@ public class ScrollPane extends Component {
|
||||
private PointF lastPos = new PointF();
|
||||
|
||||
@Override
|
||||
protected void onDrag( Touch t ) {
|
||||
protected void onDrag( PointerEvent event ) {
|
||||
if (dragging) {
|
||||
|
||||
Camera c = content.camera;
|
||||
|
||||
c.scroll.offset( PointF.diff( lastPos, t.current ).invScale( c.zoom ) );
|
||||
c.scroll.offset( PointF.diff( lastPos, event.current ).invScale( c.zoom ) );
|
||||
if (c.scroll.x + width > content.width()) {
|
||||
c.scroll.x = content.width() - width;
|
||||
}
|
||||
@@ -156,12 +156,12 @@ public class ScrollPane extends Component {
|
||||
|
||||
thumb.y = y + height * c.scroll.y / content.height();
|
||||
|
||||
lastPos.set( t.current );
|
||||
lastPos.set( event.current );
|
||||
|
||||
} else if (PointF.distance( t.current, t.start ) > dragThreshold) {
|
||||
} else if (PointF.distance( event.current, event.start ) > dragThreshold) {
|
||||
|
||||
dragging = true;
|
||||
lastPos.set( t.current );
|
||||
lastPos.set( event.current );
|
||||
thumb.am = 1;
|
||||
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.watabou.input.Touchscreen.Touch;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
|
||||
public class SimpleButton extends Component {
|
||||
@@ -43,19 +43,19 @@ public class SimpleButton extends Component {
|
||||
image = new Image();
|
||||
add( image );
|
||||
|
||||
add( new TouchArea( image ) {
|
||||
add( new PointerArea( image ) {
|
||||
@Override
|
||||
protected void onTouchDown(Touch touch) {
|
||||
protected void onPointerDown( PointerEvent event ) {
|
||||
image.brightness( 1.2f );
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected void onTouchUp(Touch touch) {
|
||||
protected void onPointerUp( PointerEvent event ) {
|
||||
image.brightness( 1.0f );
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected void onClick( Touch touch ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
SimpleButton.this.onClick();
|
||||
};
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
@@ -32,13 +32,13 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndGame;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndHero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||
import com.watabou.input.Touchscreen.Touch;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
@@ -82,9 +82,9 @@ public class StatusPane extends Component {
|
||||
bg = new NinePatch( Assets.STATUS, 0, 0, 128, 36, 85, 0, 45, 0 );
|
||||
add( bg );
|
||||
|
||||
add( new TouchArea( 0, 1, 31, 31 ) {
|
||||
add( new PointerArea( 0, 1, 31, 31 ) {
|
||||
@Override
|
||||
protected void onClick( Touch touch ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
Image sprite = Dungeon.hero.sprite;
|
||||
if (!sprite.isVisible()) {
|
||||
Camera.main.focusOn( sprite );
|
||||
@@ -322,13 +322,13 @@ public class StatusPane extends Component {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
bg.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
if (keyIcon.keyCount() > 0) {
|
||||
bg.brightness(.8f - (Math.min(6, keyIcon.keyCount()) / 20f));
|
||||
} else {
|
||||
@@ -374,13 +374,13 @@ public class StatusPane extends Component {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
image.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
image.resetColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -84,13 +84,13 @@ public class StyledButton extends Button {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
bg.brightness( 1.2f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
bg.resetColor();
|
||||
}
|
||||
|
||||
|
||||
@@ -324,12 +324,12 @@ public class Toolbar extends Component {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
base.brightness( 1.4f );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
if (active) {
|
||||
base.resetColor();
|
||||
} else {
|
||||
|
||||
@@ -24,24 +24,23 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.ShadowBox;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.input.Keys;
|
||||
import com.watabou.input.Keys.Key;
|
||||
import com.watabou.input.Touchscreen.Touch;
|
||||
import com.watabou.input.KeyEvent;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.utils.Signal;
|
||||
|
||||
public class Window extends Group implements Signal.Listener<Key> {
|
||||
public class Window extends Group implements Signal.Listener<KeyEvent> {
|
||||
|
||||
protected int width;
|
||||
protected int height;
|
||||
|
||||
protected int yOffset;
|
||||
|
||||
protected TouchArea blocker;
|
||||
protected PointerArea blocker;
|
||||
protected ShadowBox shadow;
|
||||
protected NinePatch chrome;
|
||||
|
||||
@@ -65,12 +64,12 @@ public class Window extends Group implements Signal.Listener<Key> {
|
||||
|
||||
this.yOffset = yOffset;
|
||||
|
||||
blocker = new TouchArea( 0, 0, PixelScene.uiCamera.width, PixelScene.uiCamera.height ) {
|
||||
blocker = new PointerArea( 0, 0, PixelScene.uiCamera.width, PixelScene.uiCamera.height ) {
|
||||
@Override
|
||||
protected void onClick( Touch touch ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
if (Window.this.parent != null && !Window.this.chrome.overlapsScreenPoint(
|
||||
(int)touch.current.x,
|
||||
(int)touch.current.y )) {
|
||||
(int) event.current.x,
|
||||
(int) event.current.y )) {
|
||||
|
||||
onBackPressed();
|
||||
}
|
||||
@@ -112,7 +111,7 @@ public class Window extends Group implements Signal.Listener<Key> {
|
||||
camera.y / camera.zoom,
|
||||
chrome.width(), chrome.height );
|
||||
|
||||
Keys.event.add( this );
|
||||
KeyEvent.addKeyListener( this );
|
||||
}
|
||||
|
||||
public void resize( int w, int h ) {
|
||||
@@ -151,23 +150,23 @@ public class Window extends Group implements Signal.Listener<Key> {
|
||||
super.destroy();
|
||||
|
||||
Camera.remove( camera );
|
||||
Keys.event.remove( this );
|
||||
KeyEvent.removeKeyListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignal( Key key ) {
|
||||
if (key.pressed) {
|
||||
switch (key.code) {
|
||||
case Keys.BACK:
|
||||
onBackPressed();
|
||||
break;
|
||||
case Keys.MENU:
|
||||
onMenuPressed();
|
||||
break;
|
||||
public boolean onSignal( KeyEvent event ) {
|
||||
if (event.pressed) {
|
||||
switch (event.code) {
|
||||
case KeyEvent.BACK:
|
||||
onBackPressed();
|
||||
return true;
|
||||
case KeyEvent.MENU:
|
||||
onMenuPressed();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Keys.event.cancel();
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBackPressed() {
|
||||
|
||||
+4
-4
@@ -23,18 +23,18 @@ package com.shatteredpixel.shatteredpixeldungeon.ui.changelist;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage;
|
||||
import com.watabou.input.Touchscreen;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
|
||||
public class ChangesWindow extends WndTitledMessage {
|
||||
|
||||
public ChangesWindow(Image icon, String title, String message ) {
|
||||
super( icon, title, message);
|
||||
|
||||
TouchArea blocker = new TouchArea( 0, 0, PixelScene.uiCamera.width, PixelScene.uiCamera.height ) {
|
||||
PointerArea blocker = new PointerArea( 0, 0, PixelScene.uiCamera.width, PixelScene.uiCamera.height ) {
|
||||
@Override
|
||||
protected void onClick( Touchscreen.Touch touch ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
hide();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -412,12 +412,12 @@ public class WndBag extends WndTabbed {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
bg.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK, 0.7f, 0.7f, 1.2f );
|
||||
};
|
||||
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
bg.brightness( 1.0f );
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -135,12 +135,12 @@ public class WndBlacksmith extends Window {
|
||||
|
||||
slot = new ItemSlot() {
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
bg.brightness( 1.2f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK );
|
||||
};
|
||||
@Override
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
bg.resetColor();
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -348,12 +348,12 @@ public class WndRanking extends WndTabbed {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
bg.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK, 0.7f, 0.7f, 1.2f );
|
||||
};
|
||||
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
bg.brightness( 1.0f );
|
||||
};
|
||||
|
||||
@@ -392,12 +392,12 @@ public class WndRanking extends WndTabbed {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTouchDown() {
|
||||
protected void onPointerDown() {
|
||||
bg.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.SND_CLICK, 0.7f, 0.7f, 1.2f );
|
||||
};
|
||||
|
||||
protected void onTouchUp() {
|
||||
protected void onPointerUp() {
|
||||
bg.brightness( 1.0f );
|
||||
};
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.input.Touchscreen.Touch;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.TouchArea;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.utils.SparseArray;
|
||||
|
||||
public class WndStory extends Window {
|
||||
@@ -74,9 +74,9 @@ public class WndStory extends Window {
|
||||
tf.setPos(MARGIN, 0);
|
||||
add( tf );
|
||||
|
||||
add( new TouchArea( chrome ) {
|
||||
add( new PointerArea( chrome ) {
|
||||
@Override
|
||||
protected void onClick( Touch touch ) {
|
||||
protected void onClick( PointerEvent event ) {
|
||||
hide();
|
||||
}
|
||||
} );
|
||||
|
||||
Reference in New Issue
Block a user