diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/SimpleButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/SimpleButton.java deleted file mode 100644 index 27a9f4220..000000000 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/SimpleButton.java +++ /dev/null @@ -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 - */ - -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() {} -} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toast.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toast.java index 8baccec55..709710dfc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toast.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toast.java @@ -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);