v1.3.0: fixed errors in badge display and allowed multiple at once
This commit is contained in:
+20
-13
@@ -32,6 +32,7 @@ import com.watabou.noosa.audio.Sample;
|
|||||||
import com.watabou.utils.Point;
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.PointF;
|
import com.watabou.utils.PointF;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class BadgeBanner extends Image {
|
public class BadgeBanner extends Image {
|
||||||
@@ -40,8 +41,9 @@ public class BadgeBanner extends Image {
|
|||||||
FADE_IN, STATIC, FADE_OUT
|
FADE_IN, STATIC, FADE_OUT
|
||||||
}
|
}
|
||||||
private State state;
|
private State state;
|
||||||
|
|
||||||
private static final float DEFAULT_SCALE = 3;
|
public static final float DEFAULT_SCALE = 3;
|
||||||
|
public static final int SIZE = 16;
|
||||||
|
|
||||||
private static final float FADE_IN_TIME = 0.25f;
|
private static final float FADE_IN_TIME = 0.25f;
|
||||||
private static final float STATIC_TIME = 1f;
|
private static final float STATIC_TIME = 1f;
|
||||||
@@ -52,14 +54,14 @@ public class BadgeBanner extends Image {
|
|||||||
|
|
||||||
private static TextureFilm atlas;
|
private static TextureFilm atlas;
|
||||||
|
|
||||||
private static BadgeBanner current;
|
public static ArrayList<BadgeBanner> showing = new ArrayList<>();
|
||||||
|
|
||||||
private BadgeBanner( int index ) {
|
private BadgeBanner( int index ) {
|
||||||
|
|
||||||
super( Assets.Interfaces.BADGES );
|
super( Assets.Interfaces.BADGES );
|
||||||
|
|
||||||
if (atlas == null) {
|
if (atlas == null) {
|
||||||
atlas = new TextureFilm( texture, 16, 16 );
|
atlas = new TextureFilm( texture, SIZE, SIZE );
|
||||||
}
|
}
|
||||||
|
|
||||||
setup(index);
|
setup(index);
|
||||||
@@ -124,12 +126,16 @@ public class BadgeBanner extends Image {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void kill() {
|
public void kill() {
|
||||||
if (current == this) {
|
showing.remove(this);
|
||||||
current = null;
|
|
||||||
}
|
|
||||||
super.kill();
|
super.kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
showing.remove(this);
|
||||||
|
super.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
//map to cache highlight positions so we don't have to keep looking at texture pixels
|
//map to cache highlight positions so we don't have to keep looking at texture pixels
|
||||||
private static HashMap<Integer, Point> highlightPositions = new HashMap<>();
|
private static HashMap<Integer, Point> highlightPositions = new HashMap<>();
|
||||||
|
|
||||||
@@ -192,12 +198,13 @@ public class BadgeBanner extends Image {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BadgeBanner show( int image ) {
|
public static BadgeBanner show( int image ) {
|
||||||
if (current != null) {
|
BadgeBanner banner = new BadgeBanner(image);
|
||||||
current.setup(image);
|
showing.add(banner);
|
||||||
} else {
|
return banner;
|
||||||
current = new BadgeBanner(image);
|
}
|
||||||
}
|
|
||||||
return current;
|
public static boolean isShowingBadges(){
|
||||||
|
return !showing.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Image image( int index ) {
|
public static Image image( int index ) {
|
||||||
|
|||||||
+26
-4
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Flare;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Flare;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Amulet;
|
||||||
@@ -33,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
|||||||
import com.watabou.noosa.Camera;
|
import com.watabou.noosa.Camera;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
|
import com.watabou.noosa.tweeners.Delayer;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class AmuletScene extends PixelScene {
|
public class AmuletScene extends PixelScene {
|
||||||
@@ -49,6 +51,9 @@ public class AmuletScene extends PixelScene {
|
|||||||
{
|
{
|
||||||
inGameScene = true;
|
inGameScene = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RedButton btnExit = null;
|
||||||
|
RedButton btnStay = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
@@ -63,19 +68,36 @@ public class AmuletScene extends PixelScene {
|
|||||||
|
|
||||||
amulet = new Image( Assets.Sprites.AMULET );
|
amulet = new Image( Assets.Sprites.AMULET );
|
||||||
add( amulet );
|
add( amulet );
|
||||||
|
|
||||||
RedButton btnExit = new RedButton( Messages.get(this, "exit") ) {
|
btnExit = new RedButton( Messages.get(this, "exit") ) {
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
Dungeon.win( Amulet.class );
|
Dungeon.win( Amulet.class );
|
||||||
Dungeon.deleteGame( GamesInProgress.curSlot, true );
|
Dungeon.deleteGame( GamesInProgress.curSlot, true );
|
||||||
Game.switchScene( RankingsScene.class );
|
|
||||||
|
add(new Delayer(0.1f){
|
||||||
|
@Override
|
||||||
|
protected void onComplete() {
|
||||||
|
if (BadgeBanner.isShowingBadges()){
|
||||||
|
btnExit.enable(false);
|
||||||
|
btnStay.enable(false);
|
||||||
|
AmuletScene.this.add(new Delayer(3f){
|
||||||
|
@Override
|
||||||
|
protected void onComplete() {
|
||||||
|
Game.switchScene( RankingsScene.class );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Game.switchScene( RankingsScene.class );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
btnExit.setSize( WIDTH, BTN_HEIGHT );
|
btnExit.setSize( WIDTH, BTN_HEIGHT );
|
||||||
add( btnExit );
|
add( btnExit );
|
||||||
|
|
||||||
RedButton btnStay = new RedButton( Messages.get(this, "stay") ) {
|
btnStay = new RedButton( Messages.get(this, "stay") ) {
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
|
|||||||
@@ -293,13 +293,23 @@ public class PixelScene extends Scene {
|
|||||||
Game.runOnRenderThread(new Callback() {
|
Game.runOnRenderThread(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void call() {
|
public void call() {
|
||||||
BadgeBanner banner = BadgeBanner.show( badge.image );
|
|
||||||
banner.camera = uiCamera;
|
|
||||||
float offset = Camera.main.centerOffset.y;
|
|
||||||
banner.x = align( banner.camera, (banner.camera.width - banner.width) / 2 );
|
|
||||||
banner.y = align( uiCamera, (uiCamera.height - banner.height) / 2 - banner.height/2 - 16 - offset );
|
|
||||||
Scene s = Game.scene();
|
Scene s = Game.scene();
|
||||||
if (s != null) s.add( banner );
|
if (s != null) {
|
||||||
|
BadgeBanner banner = BadgeBanner.show(badge.image);
|
||||||
|
s.add(banner);
|
||||||
|
float offset = Camera.main.centerOffset.y;
|
||||||
|
|
||||||
|
int left = uiCamera.width/2 - BadgeBanner.SIZE/2;
|
||||||
|
left -= (BadgeBanner.SIZE * BadgeBanner.DEFAULT_SCALE * (BadgeBanner.showing.size()-1))/2;
|
||||||
|
for (int i = 0; i < BadgeBanner.showing.size(); i++){
|
||||||
|
banner = BadgeBanner.showing.get(i);
|
||||||
|
banner.camera = uiCamera;
|
||||||
|
banner.x = align(banner.camera, left);
|
||||||
|
banner.y = align(uiCamera, (uiCamera.height - banner.height) / 2 - banner.height / 2 - 16 - offset);
|
||||||
|
left += BadgeBanner.SIZE * BadgeBanner.DEFAULT_SCALE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user