v2.4.0: cleaned up various allocations that occurred every frame
This commit is contained in:
@@ -62,6 +62,10 @@ public class KeyEvent {
|
||||
}
|
||||
|
||||
public static synchronized void processKeyEvents(){
|
||||
if (keyEvents.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (KeyEvent k : keyEvents){
|
||||
if (KeyBindings.getActionForKey(k) == GameAction.LEFT_CLICK){
|
||||
Game.inputHandler.emulateTouch(ControllerHandler.CONTROLLER_POINTER_ID, PointerEvent.LEFT, k.pressed);
|
||||
|
||||
@@ -136,6 +136,10 @@ public class PointerEvent {
|
||||
public static boolean clearKeyboardThisPress = true;
|
||||
|
||||
public static synchronized void processPointerEvents(){
|
||||
if (pointerEvents.isEmpty()){
|
||||
return;
|
||||
}
|
||||
|
||||
//handle any hover events separately first as we may need to add drag events
|
||||
boolean hovered = false;
|
||||
for (PointerEvent p : pointerEvents){
|
||||
|
||||
@@ -62,6 +62,10 @@ public class ScrollEvent {
|
||||
}
|
||||
|
||||
public static synchronized void processScrollEvents(){
|
||||
if (scrollEvents.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ScrollEvent k : scrollEvents){
|
||||
scrollSignal.dispatch(k);
|
||||
}
|
||||
|
||||
@@ -178,36 +178,39 @@ public class Camera extends Gizmo {
|
||||
float deadX = 0;
|
||||
float deadY = 0;
|
||||
if (followTarget != null){
|
||||
panTarget = followTarget.center().offset(centerOffset);
|
||||
//manually assign here to avoid an allocation from sprite.center()
|
||||
panTarget.x = followTarget.x + followTarget.width()/2;
|
||||
panTarget.y = followTarget.y + followTarget.height()/2;
|
||||
panTarget.offset(centerOffset);
|
||||
deadX = width * followDeadzone /2f;
|
||||
deadY = height * followDeadzone /2f;
|
||||
}
|
||||
|
||||
if (panIntensity > 0f){
|
||||
|
||||
PointF panMove = new PointF();
|
||||
panMove.x = panTarget.x - (scroll.x + width/2f);
|
||||
panMove.y = panTarget.y - (scroll.y + height/2f);
|
||||
float panX = panTarget.x - (scroll.x + width/2f);
|
||||
float panY = panTarget.y - (scroll.y + height/2f);
|
||||
|
||||
if (panMove.x > deadX){
|
||||
panMove.x -= deadX;
|
||||
} else if (panMove.x < -deadX){
|
||||
panMove.x += deadX;
|
||||
if (panX > deadX){
|
||||
panX -= deadX;
|
||||
} else if (panX < -deadX){
|
||||
panX += deadX;
|
||||
} else {
|
||||
panMove.x = 0;
|
||||
panX = 0;
|
||||
}
|
||||
|
||||
if (panMove.y > deadY){
|
||||
panMove.y -= deadY;
|
||||
} else if (panMove.y < -deadY){
|
||||
panMove.y += deadY;
|
||||
if (panY > deadY){
|
||||
panY -= deadY;
|
||||
} else if (panY < -deadY){
|
||||
panY += deadY;
|
||||
} else {
|
||||
panMove.y = 0;
|
||||
panY = 0;
|
||||
}
|
||||
|
||||
panMove.scale(Math.min(1f, Game.elapsed * panIntensity));
|
||||
panX *= Math.min(1f, Game.elapsed * panIntensity);
|
||||
panY *= Math.min(1f, Game.elapsed * panIntensity);
|
||||
|
||||
scroll.offset(panMove);
|
||||
scroll.offset(panX, panY);
|
||||
}
|
||||
|
||||
if ((shakeTime -= Game.elapsed) > 0) {
|
||||
|
||||
@@ -107,7 +107,7 @@ public class Burning extends Buff implements Hero.Doom {
|
||||
|
||||
ArrayList<Item> burnable = new ArrayList<>();
|
||||
//does not reach inside of containers
|
||||
if (hero.buff(LostInventory.class) == null) {
|
||||
if (!hero.belongings.lostInventory()) {
|
||||
for (Item i : hero.belongings.backpack.items) {
|
||||
if (!i.unique && (i instanceof Scroll || i instanceof MysteryMeat || i instanceof FrozenCarpaccio)) {
|
||||
burnable.add(i);
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Frost extends FlavourBuff {
|
||||
Hero hero = (Hero)target;
|
||||
ArrayList<Item> freezable = new ArrayList<>();
|
||||
//does not reach inside of containers
|
||||
if (hero.buff(LostInventory.class) == null) {
|
||||
if (!hero.belongings.lostInventory()) {
|
||||
for (Item i : hero.belongings.backpack.items) {
|
||||
if (!i.unique && (i instanceof Potion || i instanceof MysteryMeat)) {
|
||||
freezable.add(i);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||
|
||||
public class LostInventory extends Buff {
|
||||
@@ -29,6 +31,26 @@ public class LostInventory extends Buff {
|
||||
type = buffType.NEGATIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean attachTo( Char target ) {
|
||||
if (super.attachTo( target )) {
|
||||
if (target instanceof Hero && ((Hero) target).belongings != null){
|
||||
((Hero) target).belongings.lostInventory(true);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
super.detach();
|
||||
if (target instanceof Hero && ((Hero) target).belongings != null){
|
||||
((Hero) target).belongings.lostInventory(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int icon() {
|
||||
return BuffIndicator.NOINV;
|
||||
|
||||
@@ -101,9 +101,18 @@ public class Belongings implements Iterable<Item> {
|
||||
return weapon();
|
||||
}
|
||||
|
||||
//we cache whether belongings are lost to avoid lots of calls to hero.buff(LostInventory.class)
|
||||
private boolean lostInvent;
|
||||
public void lostInventory( boolean val ){
|
||||
lostInvent = val;
|
||||
}
|
||||
|
||||
public boolean lostInventory(){
|
||||
return lostInvent;
|
||||
}
|
||||
|
||||
public KindOfWeapon weapon(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (weapon != null && weapon.keptThroughLostInventory())){
|
||||
if (!lostInventory() || (weapon != null && weapon.keptThroughLostInventory())){
|
||||
return weapon;
|
||||
} else {
|
||||
return null;
|
||||
@@ -111,8 +120,7 @@ public class Belongings implements Iterable<Item> {
|
||||
}
|
||||
|
||||
public Armor armor(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (armor != null && armor.keptThroughLostInventory())){
|
||||
if (!lostInventory() || (armor != null && armor.keptThroughLostInventory())){
|
||||
return armor;
|
||||
} else {
|
||||
return null;
|
||||
@@ -120,8 +128,7 @@ public class Belongings implements Iterable<Item> {
|
||||
}
|
||||
|
||||
public Artifact artifact(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (artifact != null && artifact.keptThroughLostInventory())){
|
||||
if (!lostInventory() || (artifact != null && artifact.keptThroughLostInventory())){
|
||||
return artifact;
|
||||
} else {
|
||||
return null;
|
||||
@@ -129,8 +136,7 @@ public class Belongings implements Iterable<Item> {
|
||||
}
|
||||
|
||||
public KindofMisc misc(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (misc != null && misc.keptThroughLostInventory())){
|
||||
if (!lostInventory() || (misc != null && misc.keptThroughLostInventory())){
|
||||
return misc;
|
||||
} else {
|
||||
return null;
|
||||
@@ -138,8 +144,7 @@ public class Belongings implements Iterable<Item> {
|
||||
}
|
||||
|
||||
public Ring ring(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (ring != null && ring.keptThroughLostInventory())){
|
||||
if (!lostInventory() || (ring != null && ring.keptThroughLostInventory())){
|
||||
return ring;
|
||||
} else {
|
||||
return null;
|
||||
@@ -147,8 +152,7 @@ public class Belongings implements Iterable<Item> {
|
||||
}
|
||||
|
||||
public KindOfWeapon secondWep(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (secondWep != null && secondWep.keptThroughLostInventory())){
|
||||
if (!lostInventory() || (secondWep != null && secondWep.keptThroughLostInventory())){
|
||||
return secondWep;
|
||||
} else {
|
||||
return null;
|
||||
@@ -232,7 +236,7 @@ public class Belongings implements Iterable<Item> {
|
||||
@SuppressWarnings("unchecked")
|
||||
public<T extends Item> T getItem( Class<T> itemClass ) {
|
||||
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
boolean lostInvent = lostInventory();
|
||||
|
||||
for (Item item : this) {
|
||||
if (itemClass.isInstance( item )) {
|
||||
@@ -248,7 +252,7 @@ public class Belongings implements Iterable<Item> {
|
||||
public<T extends Item> ArrayList<T> getAllItems( Class<T> itemClass ) {
|
||||
ArrayList<T> result = new ArrayList<>();
|
||||
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
boolean lostInvent = lostInventory();
|
||||
|
||||
for (Item item : this) {
|
||||
if (itemClass.isInstance( item )) {
|
||||
@@ -263,7 +267,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
public boolean contains( Item contains ){
|
||||
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
boolean lostInvent = lostInventory();
|
||||
|
||||
for (Item item : this) {
|
||||
if (contains == item) {
|
||||
@@ -278,7 +282,7 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
public Item getSimilar( Item similar ){
|
||||
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
boolean lostInvent = lostInventory();
|
||||
|
||||
for (Item item : this) {
|
||||
if (similar != item && similar.isSimilar(item)) {
|
||||
@@ -294,7 +298,7 @@ public class Belongings implements Iterable<Item> {
|
||||
public ArrayList<Item> getAllSimilar( Item similar ){
|
||||
ArrayList<Item> result = new ArrayList<>();
|
||||
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
boolean lostInvent = lostInventory();
|
||||
|
||||
for (Item item : this) {
|
||||
if (item != similar && similar.isSimilar(item)) {
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.EnhancedRings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.PhysicalEmpower;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.RevealedArea;
|
||||
@@ -431,7 +430,7 @@ public enum Talent {
|
||||
if (talent == LIGHT_CLOAK && hero.heroClass == HeroClass.ROGUE){
|
||||
for (Item item : Dungeon.hero.belongings.backpack){
|
||||
if (item instanceof CloakOfShadows){
|
||||
if (hero.buff(LostInventory.class) == null || item.keptThroughLostInventory()) {
|
||||
if (!hero.belongings.lostInventory() || item.keptThroughLostInventory()) {
|
||||
((CloakOfShadows) item).activate(Dungeon.hero);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,9 @@ public class CircleArc extends Visual {
|
||||
private boolean lightMode = true;
|
||||
|
||||
private SmartTexture texture;
|
||||
|
||||
private FloatBuffer vertices;
|
||||
|
||||
protected float[] vertices;
|
||||
private FloatBuffer verticesBuffer;
|
||||
private ShortBuffer indices;
|
||||
|
||||
private int nTris;
|
||||
@@ -64,8 +65,9 @@ public class CircleArc extends Visual {
|
||||
|
||||
this.nTris = triangles;
|
||||
this.rad = radius;
|
||||
|
||||
vertices = ByteBuffer.
|
||||
|
||||
vertices = new float[4];
|
||||
verticesBuffer = ByteBuffer.
|
||||
allocateDirect( (nTris * 2 + 1) * 4 * (Float.SIZE / 8) ).
|
||||
order( ByteOrder.nativeOrder() ).
|
||||
asFloatBuffer();
|
||||
@@ -105,8 +107,10 @@ public class CircleArc extends Visual {
|
||||
}
|
||||
|
||||
public void setSweep( float sweep ){
|
||||
this.sweep = sweep;
|
||||
dirty = true;
|
||||
if (sweep != this.sweep) {
|
||||
this.sweep = sweep;
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public float getSweep(){
|
||||
@@ -116,19 +120,18 @@ public class CircleArc extends Visual {
|
||||
private void updateTriangles(){
|
||||
|
||||
dirty = false;
|
||||
float v[] = new float[4];
|
||||
|
||||
((Buffer)indices).position( 0 );
|
||||
((Buffer)vertices).position( 0 );
|
||||
((Buffer)verticesBuffer).position( 0 );
|
||||
|
||||
v[0] = 0;
|
||||
v[1] = 0;
|
||||
v[2] = 0.25f;
|
||||
v[3] = 0;
|
||||
vertices.put( v );
|
||||
|
||||
v[2] = 0.75f;
|
||||
v[3] = 0;
|
||||
vertices[0] = 0;
|
||||
vertices[1] = 0;
|
||||
vertices[2] = 0.25f;
|
||||
vertices[3] = 0;
|
||||
verticesBuffer.put( vertices );
|
||||
|
||||
vertices[2] = 0.75f;
|
||||
vertices[3] = 0;
|
||||
|
||||
//starting position is very top by default, use angle to adjust this.
|
||||
double start = 2 * (Math.PI - Math.PI*sweep) - Math.PI/2.0;
|
||||
@@ -136,14 +139,14 @@ public class CircleArc extends Visual {
|
||||
for (int i = 0; i < nTris; i++) {
|
||||
|
||||
double a = start + i * Math.PI * 2 / nTris * sweep;
|
||||
v[0] = (float)Math.cos( a ) * rad;
|
||||
v[1] = (float)Math.sin( a ) * rad;
|
||||
vertices.put( v );
|
||||
vertices[0] = (float)Math.cos( a ) * rad;
|
||||
vertices[1] = (float)Math.sin( a ) * rad;
|
||||
verticesBuffer.put( vertices );
|
||||
|
||||
a += 3.1415926f * 2 / nTris * sweep;
|
||||
v[0] = (float)Math.cos( a ) * rad;
|
||||
v[1] = (float)Math.sin( a ) * rad;
|
||||
vertices.put( v );
|
||||
vertices[0] = (float)Math.cos( a ) * rad;
|
||||
vertices[1] = (float)Math.sin( a ) * rad;
|
||||
verticesBuffer.put( vertices );
|
||||
|
||||
indices.put( (short)0 );
|
||||
indices.put( (short)(1 + i * 2) );
|
||||
@@ -189,7 +192,7 @@ public class CircleArc extends Visual {
|
||||
ra, ga, ba, aa );
|
||||
|
||||
script.camera( camera );
|
||||
script.drawElements( vertices, indices, nTris * 3 );
|
||||
script.drawElements( verticesBuffer, indices, nTris * 3 );
|
||||
|
||||
if (lightMode) Blending.setNormalMode();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.items;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.MagicImmune;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
|
||||
@@ -127,7 +126,7 @@ public abstract class EquipableItem extends Item {
|
||||
|
||||
if (cursed
|
||||
&& hero.buff(MagicImmune.class) == null
|
||||
&& (hero.buff(LostInventory.class) == null || keptThroughLostInventory())) {
|
||||
&& (!hero.belongings.lostInventory() || keptThroughLostInventory())) {
|
||||
GLog.w(Messages.get(EquipableItem.class, "unequip_cursed"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Eye;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Beam;
|
||||
@@ -242,7 +241,7 @@ public class SentryRoom extends SpecialRoom {
|
||||
if (fieldOfView[Dungeon.hero.pos]
|
||||
&& Dungeon.level.map[Dungeon.hero.pos] == Terrain.EMPTY_SP
|
||||
&& room.inside(Dungeon.level.cellToPoint(Dungeon.hero.pos))
|
||||
&& Dungeon.hero.buff(LostInventory.class) == null){
|
||||
&& !Dungeon.hero.belongings.lostInventory()){
|
||||
|
||||
if (curChargeDelay > 0.001f){ //helps prevent rounding errors
|
||||
if (curChargeDelay == initialChargeDelay) {
|
||||
|
||||
@@ -356,13 +356,17 @@ public class CellSelector extends ScrollArea {
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (GameScene.interfaceBlockingHero()){
|
||||
return;
|
||||
}
|
||||
|
||||
GameAction newLeftStick = actionFromStick(ControllerHandler.leftStickPosition.x,
|
||||
ControllerHandler.leftStickPosition.y);
|
||||
|
||||
//skip logic here if there's no input, or if input is blocked
|
||||
if ((newLeftStick == leftStickAction
|
||||
&& leftStickAction == GameAction.NONE
|
||||
&& heldAction1 == SPDAction.NONE)
|
||||
|| GameScene.interfaceBlockingHero()){
|
||||
return;
|
||||
}
|
||||
|
||||
if (newLeftStick != leftStickAction){
|
||||
if (leftStickAction == SPDAction.NONE){
|
||||
heldDelay = initialDelay();
|
||||
|
||||
@@ -757,11 +757,13 @@ public class GameScene extends PixelScene {
|
||||
}
|
||||
|
||||
cellSelector.enable(Dungeon.hero.ready);
|
||||
|
||||
for (Gizmo g : toDestroy){
|
||||
g.destroy();
|
||||
|
||||
if (!toDestroy.isEmpty()) {
|
||||
for (Gizmo g : toDestroy) {
|
||||
g.destroy();
|
||||
}
|
||||
toDestroy.clear();
|
||||
}
|
||||
toDestroy.clear();
|
||||
}
|
||||
|
||||
private static Point lastOffset = null;
|
||||
|
||||
@@ -53,78 +53,79 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
||||
|
||||
@Override
|
||||
public synchronized void update() {
|
||||
int maxLines = SPDSettings.interfaceSize() > 0 ? 5 : 3;
|
||||
for (String text : textsToAdd){
|
||||
if (length != entries.size()){
|
||||
clear();
|
||||
recreateLines();
|
||||
}
|
||||
|
||||
if (text.equals( GLog.NEW_LINE )){
|
||||
lastEntry = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
int color = CharSprite.DEFAULT;
|
||||
if (text.startsWith( GLog.POSITIVE )) {
|
||||
text = text.substring( GLog.POSITIVE.length() );
|
||||
color = CharSprite.POSITIVE;
|
||||
} else
|
||||
if (text.startsWith( GLog.NEGATIVE )) {
|
||||
text = text.substring( GLog.NEGATIVE.length() );
|
||||
color = CharSprite.NEGATIVE;
|
||||
} else
|
||||
if (text.startsWith( GLog.WARNING )) {
|
||||
text = text.substring( GLog.WARNING.length() );
|
||||
color = CharSprite.WARNING;
|
||||
} else
|
||||
if (text.startsWith( GLog.HIGHLIGHT )) {
|
||||
text = text.substring( GLog.HIGHLIGHT.length() );
|
||||
color = CharSprite.NEUTRAL;
|
||||
}
|
||||
|
||||
if (lastEntry != null && color == lastColor && lastEntry.nLines < maxLines) {
|
||||
|
||||
String lastMessage = lastEntry.text();
|
||||
lastEntry.text( lastMessage.length() == 0 ? text : lastMessage + " " + text );
|
||||
|
||||
entries.get( entries.size() - 1 ).text = lastEntry.text();
|
||||
|
||||
} else {
|
||||
|
||||
lastEntry = PixelScene.renderTextBlock( text, 6 );
|
||||
lastEntry.setHightlighting( false );
|
||||
lastEntry.hardlight( color );
|
||||
lastColor = color;
|
||||
add( lastEntry );
|
||||
|
||||
entries.add( new Entry( text, color ) );
|
||||
|
||||
}
|
||||
|
||||
if (length > 0) {
|
||||
int nLines;
|
||||
do {
|
||||
nLines = 0;
|
||||
for (int i = 0; i < length-1; i++) {
|
||||
nLines += ((RenderedTextBlock) members.get(i)).nLines;
|
||||
}
|
||||
|
||||
if (nLines > maxLines) {
|
||||
RenderedTextBlock r = ((RenderedTextBlock) members.get(0));
|
||||
remove(r);
|
||||
r.destroy();
|
||||
|
||||
entries.remove( 0 );
|
||||
}
|
||||
} while (nLines > maxLines);
|
||||
if (entries.isEmpty()) {
|
||||
if (!textsToAdd.isEmpty()){
|
||||
int maxLines = SPDSettings.interfaceSize() > 0 ? 5 : 3;
|
||||
for (String text : textsToAdd){
|
||||
if (length != entries.size()){
|
||||
clear();
|
||||
recreateLines();
|
||||
}
|
||||
|
||||
if (text.equals( GLog.NEW_LINE )){
|
||||
lastEntry = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
int color = CharSprite.DEFAULT;
|
||||
if (text.startsWith( GLog.POSITIVE )) {
|
||||
text = text.substring( GLog.POSITIVE.length() );
|
||||
color = CharSprite.POSITIVE;
|
||||
} else
|
||||
if (text.startsWith( GLog.NEGATIVE )) {
|
||||
text = text.substring( GLog.NEGATIVE.length() );
|
||||
color = CharSprite.NEGATIVE;
|
||||
} else
|
||||
if (text.startsWith( GLog.WARNING )) {
|
||||
text = text.substring( GLog.WARNING.length() );
|
||||
color = CharSprite.WARNING;
|
||||
} else
|
||||
if (text.startsWith( GLog.HIGHLIGHT )) {
|
||||
text = text.substring( GLog.HIGHLIGHT.length() );
|
||||
color = CharSprite.NEUTRAL;
|
||||
}
|
||||
|
||||
if (lastEntry != null && color == lastColor && lastEntry.nLines < maxLines) {
|
||||
|
||||
String lastMessage = lastEntry.text();
|
||||
lastEntry.text( lastMessage.length() == 0 ? text : lastMessage + " " + text );
|
||||
|
||||
entries.get( entries.size() - 1 ).text = lastEntry.text();
|
||||
|
||||
} else {
|
||||
|
||||
lastEntry = PixelScene.renderTextBlock( text, 6 );
|
||||
lastEntry.setHightlighting( false );
|
||||
lastEntry.hardlight( color );
|
||||
lastColor = color;
|
||||
add( lastEntry );
|
||||
|
||||
entries.add( new Entry( text, color ) );
|
||||
|
||||
}
|
||||
|
||||
if (length > 0) {
|
||||
int nLines;
|
||||
do {
|
||||
nLines = 0;
|
||||
for (int i = 0; i < length-1; i++) {
|
||||
nLines += ((RenderedTextBlock) members.get(i)).nLines;
|
||||
}
|
||||
|
||||
if (nLines > maxLines) {
|
||||
RenderedTextBlock r = ((RenderedTextBlock) members.get(0));
|
||||
remove(r);
|
||||
r.destroy();
|
||||
|
||||
entries.remove( 0 );
|
||||
}
|
||||
} while (nLines > maxLines);
|
||||
if (entries.isEmpty()) {
|
||||
lastEntry = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!textsToAdd.isEmpty()){
|
||||
|
||||
layout();
|
||||
textsToAdd.clear();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
|
||||
@@ -361,7 +360,7 @@ public class InventoryPane extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
boolean lostInvent = Dungeon.hero.buff(LostInventory.class) != null;
|
||||
boolean lostInvent = Dungeon.hero.belongings.lostInventory();
|
||||
for (InventorySlot b : equipped){
|
||||
b.enable(lastEnabled
|
||||
&& !(b.item() instanceof WndBag.Placeholder)
|
||||
@@ -451,7 +450,7 @@ public class InventoryPane extends Component {
|
||||
if (lastEnabled != (Dungeon.hero.ready || !Dungeon.hero.isAlive())) {
|
||||
lastEnabled = (Dungeon.hero.ready || !Dungeon.hero.isAlive());
|
||||
|
||||
boolean lostInvent = Dungeon.hero.buff(LostInventory.class) != null;
|
||||
boolean lostInvent = Dungeon.hero.belongings.lostInventory();
|
||||
for (InventorySlot b : equipped){
|
||||
b.enable(lastEnabled
|
||||
&& !(b.item() instanceof WndBag.Placeholder)
|
||||
|
||||
@@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
@@ -101,7 +100,7 @@ public class InventorySlot extends ItemSlot {
|
||||
|
||||
if (item.name() == null) {
|
||||
enable( false );
|
||||
} else if (Dungeon.hero.buff(LostInventory.class) != null
|
||||
} else if (Dungeon.hero.belongings.lostInventory()
|
||||
&& !item.keptThroughLostInventory()){
|
||||
enable(false);
|
||||
}
|
||||
|
||||
@@ -28,18 +28,17 @@ import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Waterskin;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.watabou.utils.BArray;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.utils.BArray;
|
||||
import com.watabou.utils.PathFinder;
|
||||
|
||||
public class QuickSlotButton extends Button {
|
||||
@@ -304,7 +303,7 @@ public class QuickSlotButton extends Button {
|
||||
|
||||
private void enableSlot() {
|
||||
slot.enable(Dungeon.quickslot.isNonePlaceholder( slotNum )
|
||||
&& (Dungeon.hero.buff(LostInventory.class) == null || Dungeon.quickslot.getItem(slotNum).keptThroughLostInventory()));
|
||||
&& (!Dungeon.hero.belongings.lostInventory() || Dungeon.quickslot.getItem(slotNum).keptThroughLostInventory()));
|
||||
}
|
||||
|
||||
public void slotMargins( int left, int top, int right, int bottom){
|
||||
|
||||
@@ -235,6 +235,10 @@ public class StatusPane extends Component {
|
||||
|
||||
private static final int[] warningColors = new int[]{0x660000, 0xCC0000, 0x660000};
|
||||
|
||||
private int oldHP = 0;
|
||||
private int oldShield = 0;
|
||||
private int oldMax = 0;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
@@ -265,10 +269,15 @@ public class StatusPane extends Component {
|
||||
rawShielding.scale.x = 0;
|
||||
}
|
||||
|
||||
if (shield <= 0){
|
||||
hpText.text(health + "/" + max);
|
||||
} else {
|
||||
hpText.text(health + "+" + shield + "/" + max);
|
||||
if (oldHP != health || oldShield != shield || oldMax != max){
|
||||
if (shield <= 0) {
|
||||
hpText.text(health + "/" + max);
|
||||
} else {
|
||||
hpText.text(health + "+" + shield + "/" + max);
|
||||
}
|
||||
oldHP = health;
|
||||
oldShield = shield;
|
||||
oldMax = max;
|
||||
}
|
||||
|
||||
if (large) {
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.HoldFast;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LostInventory;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
@@ -128,7 +127,7 @@ public class Toolbar extends Component {
|
||||
Item item = Dungeon.quickslot.getItem(i);
|
||||
|
||||
if (item != null && !Dungeon.quickslot.isPlaceholder(i) &&
|
||||
(Dungeon.hero.buff(LostInventory.class) == null || item.keptThroughLostInventory())){
|
||||
(!Dungeon.hero.belongings.lostInventory() || item.keptThroughLostInventory())){
|
||||
slotNames[i] = Messages.titleCase(item.name());
|
||||
slotIcons[i] = new ItemSprite(item);
|
||||
} else {
|
||||
@@ -154,7 +153,7 @@ public class Toolbar extends Component {
|
||||
Item item = Dungeon.quickslot.getItem(idx);
|
||||
|
||||
if (item == null || Dungeon.quickslot.isPlaceholder(idx)
|
||||
|| (Dungeon.hero.buff(LostInventory.class) != null && !item.keptThroughLostInventory())
|
||||
|| (Dungeon.hero.belongings.lostInventory() && !item.keptThroughLostInventory())
|
||||
|| alt){
|
||||
//TODO would be nice to use a radial menu for this too
|
||||
// Also a bunch of code could be moved out of here into subclasses of RadialMenu
|
||||
@@ -420,7 +419,7 @@ public class Toolbar extends Component {
|
||||
|
||||
for(Item i : bag.items){
|
||||
if (i instanceof Bag) items.remove(i);
|
||||
if (Dungeon.hero.buff(LostInventory.class) != null && !i.keptThroughLostInventory()) items.remove(i);
|
||||
if (Dungeon.hero.belongings.lostInventory() && !i.keptThroughLostInventory()) items.remove(i);
|
||||
}
|
||||
|
||||
if (idx == 0){
|
||||
|
||||
Reference in New Issue
Block a user