v1.2.1: cell selector prompts are not properly closed with the back key

This commit is contained in:
Evan Debenham 2022-03-28 22:45:56 -04:00
parent aca18e8b58
commit db6559497d
2 changed files with 9 additions and 71 deletions

View File

@ -1,69 +0,0 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2022 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.watabou.input.PointerEvent;
import com.watabou.noosa.Image;
import com.watabou.noosa.PointerArea;
import com.watabou.noosa.ui.Component;
public class SimpleButton extends Component {
private Image image;
public SimpleButton( Image image ) {
super();
this.image.copy( image );
width = image.width;
height = image.height;
}
@Override
protected void createChildren() {
image = new Image();
add( image );
add( new PointerArea( image ) {
@Override
protected void onPointerDown( PointerEvent event ) {
image.brightness( 1.2f );
}
@Override
protected void onPointerUp( PointerEvent event ) {
image.brightness( 1.0f );
}
@Override
protected void onClick( PointerEvent event ) {
SimpleButton.this.onClick();
}
} );
}
@Override
protected void layout() {
image.x = x;
image.y = y;
}
protected void onClick() {}
}

View File

@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.watabou.input.GameAction;
import com.watabou.noosa.NinePatch;
import com.watabou.noosa.ui.Component;
@ -32,7 +33,7 @@ public class Toast extends Component {
private static final float MARGIN_VER = 2;
protected NinePatch bg;
protected SimpleButton close;
protected IconButton close;
protected RenderedTextBlock text;
public Toast( String text ) {
@ -50,11 +51,17 @@ public class Toast extends Component {
bg = Chrome.get( Chrome.Type.TOAST_TR );
add( bg );
close = new SimpleButton( Icons.get( Icons.CLOSE ) ) {
close = new IconButton( Icons.get( Icons.CLOSE ) ) {
protected void onClick() {
onClose();
}
@Override
public GameAction keyAction() {
return GameAction.BACK;
}
};
close.setSize(close.icon.width(), close.icon.height());
add( close );
text = PixelScene.renderTextBlock(8);