v0.3.3a: added some safety checks to GameLog
This commit is contained in:
@@ -53,6 +53,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
|||||||
for (Entry entry : entries) {
|
for (Entry entry : entries) {
|
||||||
lastEntry = PixelScene.createMultiline( entry.text, 6 );
|
lastEntry = PixelScene.createMultiline( entry.text, 6 );
|
||||||
lastEntry.hardlight( lastColor = entry.color );
|
lastEntry.hardlight( lastColor = entry.color );
|
||||||
|
lastEntry.measure();
|
||||||
add( lastEntry );
|
add( lastEntry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,6 +65,11 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
|||||||
@Override
|
@Override
|
||||||
public void onSignal( String text ) {
|
public void onSignal( String text ) {
|
||||||
|
|
||||||
|
if (length != entries.size()){
|
||||||
|
clear();
|
||||||
|
recreateLines();
|
||||||
|
}
|
||||||
|
|
||||||
int color = CharSprite.DEFAULT;
|
int color = CharSprite.DEFAULT;
|
||||||
if (text.startsWith( GLog.POSITIVE )) {
|
if (text.startsWith( GLog.POSITIVE )) {
|
||||||
text = text.substring( GLog.POSITIVE.length() );
|
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 = PixelScene.createMultiline( text, 6 );
|
||||||
lastEntry.hardlight( color );
|
lastEntry.hardlight( color );
|
||||||
|
lastEntry.measure();
|
||||||
lastColor = color;
|
lastColor = color;
|
||||||
add( lastEntry );
|
add( lastEntry );
|
||||||
|
|
||||||
@@ -108,7 +115,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
|||||||
int nLines;
|
int nLines;
|
||||||
do {
|
do {
|
||||||
nLines = 0;
|
nLines = 0;
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length-1; i++) {
|
||||||
nLines += ((BitmapTextMultiline) members.get(i)).nLines;
|
nLines += ((BitmapTextMultiline) members.get(i)).nLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user