v0.3.4: added rendered text to a few more places
This commit is contained in:
committed by
Evan Debenham
parent
e01e408f77
commit
de99b6110f
@@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.watabou.noosa.RenderedTextMultiline;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
@@ -37,7 +37,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
||||
|
||||
private static final Pattern PUNCTUATION = Pattern.compile( ".*[.,;?! ]$" );
|
||||
|
||||
private BitmapTextMultiline lastEntry;
|
||||
private RenderedTextMultiline lastEntry;
|
||||
private int lastColor;
|
||||
|
||||
private static ArrayList<Entry> entries = new ArrayList<Entry>();
|
||||
@@ -51,9 +51,8 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
||||
|
||||
private void recreateLines() {
|
||||
for (Entry entry : entries) {
|
||||
lastEntry = PixelScene.createMultiline( entry.text, 6 );
|
||||
lastEntry = PixelScene.renderMultiline( entry.text, 6 );
|
||||
lastEntry.hardlight( lastColor = entry.color );
|
||||
lastEntry.measure();
|
||||
add( lastEntry );
|
||||
}
|
||||
}
|
||||
@@ -95,15 +94,13 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
||||
|
||||
String lastMessage = lastEntry.text();
|
||||
lastEntry.text( lastMessage.length() == 0 ? text : lastMessage + " " + text );
|
||||
lastEntry.measure();
|
||||
|
||||
entries.get( entries.size() - 1 ).text = lastEntry.text();
|
||||
|
||||
} else {
|
||||
|
||||
lastEntry = PixelScene.createMultiline( text, 6 );
|
||||
lastEntry = PixelScene.renderMultiline( text, 6 );
|
||||
lastEntry.hardlight( color );
|
||||
lastEntry.measure();
|
||||
lastColor = color;
|
||||
add( lastEntry );
|
||||
|
||||
@@ -116,7 +113,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
||||
do {
|
||||
nLines = 0;
|
||||
for (int i = 0; i < length-1; i++) {
|
||||
nLines += ((BitmapTextMultiline) members.get(i)).nLines;
|
||||
nLines += ((RenderedTextMultiline) members.get(i)).nLines;
|
||||
}
|
||||
|
||||
if (nLines > MAX_LINES) {
|
||||
@@ -137,11 +134,9 @@ public class GameLog extends Component implements Signal.Listener<String> {
|
||||
protected void layout() {
|
||||
float pos = y;
|
||||
for (int i=length-1; i >= 0; i--) {
|
||||
BitmapTextMultiline entry = (BitmapTextMultiline)members.get( i );
|
||||
entry.maxWidth = (int)width;
|
||||
entry.measure();
|
||||
entry.x = x;
|
||||
entry.y = pos - entry.height();
|
||||
RenderedTextMultiline entry = (RenderedTextMultiline)members.get( i );
|
||||
entry.maxWidth((int)width);
|
||||
entry.setPos(x, pos-entry.height());
|
||||
pos -= entry.height();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.RenderedTextMultiline;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
@@ -33,7 +33,7 @@ public class Toast extends Component {
|
||||
|
||||
protected NinePatch bg;
|
||||
protected SimpleButton close;
|
||||
protected BitmapText text;
|
||||
protected RenderedTextMultiline text;
|
||||
|
||||
public Toast( String text ) {
|
||||
super();
|
||||
@@ -57,7 +57,7 @@ public class Toast extends Component {
|
||||
};
|
||||
add( close );
|
||||
|
||||
text = PixelScene.createMultiline(8);
|
||||
text = PixelScene.renderMultiline(8);
|
||||
add( text );
|
||||
}
|
||||
|
||||
@@ -72,14 +72,12 @@ public class Toast extends Component {
|
||||
close.setPos(
|
||||
bg.x + bg.width() - bg.marginHor() / 2 - MARGIN_HOR - close.width(),
|
||||
y + (height - close.height()) / 2 );
|
||||
|
||||
text.x = close.left() - MARGIN_HOR - text.width();
|
||||
text.y = y + (height - text.height()) / 2;
|
||||
|
||||
text.setPos(close.left() - MARGIN_HOR - text.width(), y + (height - text.height()) / 2);
|
||||
}
|
||||
|
||||
public void text( String txt ) {
|
||||
text.text( txt );
|
||||
text.measure();
|
||||
}
|
||||
|
||||
protected void onClose() {};
|
||||
|
||||
Reference in New Issue
Block a user