v0.3.4: added rendered text to a few more places

This commit is contained in:
Evan Debenham 2016-01-13 19:55:25 -05:00 committed by Evan Debenham
parent e01e408f77
commit de99b6110f
6 changed files with 30 additions and 36 deletions

View File

@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.RenderedTextMultiline;
import com.watabou.noosa.ui.Component; import com.watabou.noosa.ui.Component;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; 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 static final Pattern PUNCTUATION = Pattern.compile( ".*[.,;?! ]$" );
private BitmapTextMultiline lastEntry; private RenderedTextMultiline lastEntry;
private int lastColor; private int lastColor;
private static ArrayList<Entry> entries = new ArrayList<Entry>(); private static ArrayList<Entry> entries = new ArrayList<Entry>();
@ -51,9 +51,8 @@ public class GameLog extends Component implements Signal.Listener<String> {
private void recreateLines() { private void recreateLines() {
for (Entry entry : entries) { for (Entry entry : entries) {
lastEntry = PixelScene.createMultiline( entry.text, 6 ); lastEntry = PixelScene.renderMultiline( entry.text, 6 );
lastEntry.hardlight( lastColor = entry.color ); lastEntry.hardlight( lastColor = entry.color );
lastEntry.measure();
add( lastEntry ); add( lastEntry );
} }
} }
@ -95,15 +94,13 @@ public class GameLog extends Component implements Signal.Listener<String> {
String lastMessage = lastEntry.text(); String lastMessage = lastEntry.text();
lastEntry.text( lastMessage.length() == 0 ? text : lastMessage + " " + text ); lastEntry.text( lastMessage.length() == 0 ? text : lastMessage + " " + text );
lastEntry.measure();
entries.get( entries.size() - 1 ).text = lastEntry.text(); entries.get( entries.size() - 1 ).text = lastEntry.text();
} else { } else {
lastEntry = PixelScene.createMultiline( text, 6 ); lastEntry = PixelScene.renderMultiline( text, 6 );
lastEntry.hardlight( color ); lastEntry.hardlight( color );
lastEntry.measure();
lastColor = color; lastColor = color;
add( lastEntry ); add( lastEntry );
@ -116,7 +113,7 @@ public class GameLog extends Component implements Signal.Listener<String> {
do { do {
nLines = 0; nLines = 0;
for (int i = 0; i < length-1; i++) { for (int i = 0; i < length-1; i++) {
nLines += ((BitmapTextMultiline) members.get(i)).nLines; nLines += ((RenderedTextMultiline) members.get(i)).nLines;
} }
if (nLines > MAX_LINES) { if (nLines > MAX_LINES) {
@ -137,11 +134,9 @@ public class GameLog extends Component implements Signal.Listener<String> {
protected void layout() { protected void layout() {
float pos = y; float pos = y;
for (int i=length-1; i >= 0; i--) { for (int i=length-1; i >= 0; i--) {
BitmapTextMultiline entry = (BitmapTextMultiline)members.get( i ); RenderedTextMultiline entry = (RenderedTextMultiline)members.get( i );
entry.maxWidth = (int)width; entry.maxWidth((int)width);
entry.measure(); entry.setPos(x, pos-entry.height());
entry.x = x;
entry.y = pos - entry.height();
pos -= entry.height(); pos -= entry.height();
} }
} }

View File

@ -20,8 +20,8 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.ui; package com.shatteredpixel.shatteredpixeldungeon.ui;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.NinePatch; import com.watabou.noosa.NinePatch;
import com.watabou.noosa.RenderedTextMultiline;
import com.watabou.noosa.ui.Component; import com.watabou.noosa.ui.Component;
import com.shatteredpixel.shatteredpixeldungeon.Chrome; import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
@ -33,7 +33,7 @@ public class Toast extends Component {
protected NinePatch bg; protected NinePatch bg;
protected SimpleButton close; protected SimpleButton close;
protected BitmapText text; protected RenderedTextMultiline text;
public Toast( String text ) { public Toast( String text ) {
super(); super();
@ -57,7 +57,7 @@ public class Toast extends Component {
}; };
add( close ); add( close );
text = PixelScene.createMultiline(8); text = PixelScene.renderMultiline(8);
add( text ); add( text );
} }
@ -73,13 +73,11 @@ public class Toast extends Component {
bg.x + bg.width() - bg.marginHor() / 2 - MARGIN_HOR - close.width(), bg.x + bg.width() - bg.marginHor() / 2 - MARGIN_HOR - close.width(),
y + (height - close.height()) / 2 ); y + (height - close.height()) / 2 );
text.x = close.left() - MARGIN_HOR - text.width(); text.setPos(close.left() - MARGIN_HOR - text.width(), y + (height - text.height()) / 2);
text.y = y + (height - text.height()) / 2;
} }
public void text( String txt ) { public void text( String txt ) {
text.text( txt ); text.text( txt );
text.measure();
} }
protected void onClose() {}; protected void onClose() {};

View File

@ -20,14 +20,15 @@
*/ */
package com.shatteredpixel.shatteredpixeldungeon.windows; package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.items.TomeOfMastery; import com.shatteredpixel.shatteredpixeldungeon.items.TomeOfMastery;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.HighlightedText;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.noosa.RenderedTextMultiline;
public class WndChooseWay extends Window { public class WndChooseWay extends Window {
@ -45,7 +46,7 @@ public class WndChooseWay extends Window {
titlebar.setRect( 0, 0, WIDTH, 0 ); titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar ); add( titlebar );
HighlightedText hl = new HighlightedText( 6 ); RenderedTextMultiline hl = PixelScene.renderMultiline( 6 );
hl.text( way1.desc() + "\n\n" + way2.desc() + "\n\n" + Messages.get(this, "message"), WIDTH ); hl.text( way1.desc() + "\n\n" + way2.desc() + "\n\n" + Messages.get(this, "message"), WIDTH );
hl.setPos( titlebar.left(), titlebar.bottom() + GAP ); hl.setPos( titlebar.left(), titlebar.bottom() + GAP );
add( hl ); add( hl );

View File

@ -21,15 +21,15 @@
package com.shatteredpixel.shatteredpixeldungeon.windows; package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Group; import com.watabou.noosa.Group;
import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.HighlightedText;
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
import com.watabou.noosa.RenderedText; import com.watabou.noosa.RenderedText;
import com.watabou.noosa.RenderedTextMultiline;
public class WndClass extends WndTabbed { public class WndClass extends WndTabbed {
@ -116,19 +116,18 @@ public class WndClass extends WndTabbed {
pos += GAP; pos += GAP;
} }
RenderedText dot = PixelScene.renderText( DOT, 6 ); BitmapText dot = PixelScene.createText( DOT, 6 );
dot.x = MARGIN; dot.x = MARGIN;
dot.y = pos; dot.y = pos;
if (dotWidth == 0) { if (dotWidth == 0) {
dot.measure();
dotWidth = dot.width(); dotWidth = dot.width();
} }
add( dot ); add( dot );
BitmapTextMultiline item = PixelScene.createMultiline( items[i], 6 ); RenderedTextMultiline item = PixelScene.renderMultiline( items[i], 6 );
item.x = dot.x + dotWidth; item.maxWidth((int)(WIDTH - MARGIN * 2 - dotWidth));
item.y = pos; item.setPos(dot.x + dotWidth, pos);
item.maxWidth = (int)(WIDTH - MARGIN * 2 - dotWidth);
item.measure();
add( item ); add( item );
pos += item.height(); pos += item.height();
@ -169,7 +168,7 @@ public class WndClass extends WndTabbed {
break; break;
} }
HighlightedText text = new HighlightedText( 6 ); RenderedTextMultiline text = PixelScene.renderMultiline( 6 );
text.text( message, WIDTH - MARGIN * 2 ); text.text( message, WIDTH - MARGIN * 2 );
text.setPos( MARGIN, MARGIN ); text.setPos( MARGIN, MARGIN );
add( text ); add( text );

View File

@ -21,11 +21,11 @@
package com.shatteredpixel.shatteredpixeldungeon.windows; package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.ui.HighlightedText;
import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.BitmapTextMultiline;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.watabou.noosa.RenderedTextMultiline;
public class WndOptions extends Window { public class WndOptions extends Window {
@ -47,7 +47,7 @@ public class WndOptions extends Window {
tfTitle.measure(); tfTitle.measure();
add( tfTitle ); add( tfTitle );
HighlightedText tfMesage = new HighlightedText( 6 ); RenderedTextMultiline tfMesage = PixelScene.renderMultiline( 6 );
tfMesage.text(message, width - MARGIN * 2); tfMesage.text(message, width - MARGIN * 2);
tfMesage.setPos( MARGIN, tfTitle.y + tfTitle.height() + MARGIN ); tfMesage.setPos( MARGIN, tfTitle.y + tfTitle.height() + MARGIN );
add( tfMesage ); add( tfMesage );

View File

@ -21,8 +21,9 @@
package com.shatteredpixel.shatteredpixeldungeon.windows; package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.ui.HighlightedText; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.RenderedTextMultiline;
import com.watabou.noosa.ui.Component; import com.watabou.noosa.ui.Component;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
@ -47,7 +48,7 @@ public class WndTitledMessage extends Window {
titlebar.setRect( 0, 0, width, 0 ); titlebar.setRect( 0, 0, width, 0 );
add(titlebar); add(titlebar);
HighlightedText text = new HighlightedText( 6 ); RenderedTextMultiline text = PixelScene.renderMultiline( 6 );
text.text( message, width ); text.text( message, width );
text.setPos( titlebar.left(), titlebar.bottom() + GAP ); text.setPos( titlebar.left(), titlebar.bottom() + GAP );
add( text ); add( text );