v0.3.3a: added some safety checks to GameLog

This commit is contained in:
Evan Debenham 2015-12-23 04:21:52 -05:00
parent 75e232a429
commit 69a377c53f

View File

@ -53,6 +53,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
for (Entry entry : entries) {
lastEntry = PixelScene.createMultiline( entry.text, 6 );
lastEntry.hardlight( lastColor = entry.color );
lastEntry.measure();
add( lastEntry );
}
}
@ -64,6 +65,11 @@ public class GameLog extends Component implements Signal.Listener<String> {
@Override
public void onSignal( String text ) {
if (length != entries.size()){
clear();
recreateLines();
}
int color = CharSprite.DEFAULT;
if (text.startsWith( GLog.POSITIVE )) {
text = text.substring( GLog.POSITIVE.length() );
@ -97,6 +103,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
lastEntry = PixelScene.createMultiline( text, 6 );
lastEntry.hardlight( color );
lastEntry.measure();
lastColor = color;
add( lastEntry );
@ -108,7 +115,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
int nLines;
do {
nLines = 0;
for (int i = 0; i < length; i++) {
for (int i = 0; i < length-1; i++) {
nLines += ((BitmapTextMultiline) members.get(i)).nLines;
}