v0.3.4: added rendered text to a few more places
This commit is contained in:
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 );
|
||||
}
|
||||
|
||||
|
@ -73,13 +73,11 @@ public class Toast extends Component {
|
|||
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() {};
|
||||
|
|
|
@ -20,14 +20,15 @@
|
|||
*/
|
||||
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.items.TomeOfMastery;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HighlightedText;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.noosa.RenderedTextMultiline;
|
||||
|
||||
public class WndChooseWay extends Window {
|
||||
|
||||
|
@ -45,7 +46,7 @@ public class WndChooseWay extends Window {
|
|||
titlebar.setRect( 0, 0, WIDTH, 0 );
|
||||
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.setPos( titlebar.left(), titlebar.bottom() + GAP );
|
||||
add( hl );
|
||||
|
|
|
@ -21,15 +21,15 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Badges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HighlightedText;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||
import com.watabou.noosa.RenderedText;
|
||||
import com.watabou.noosa.RenderedTextMultiline;
|
||||
|
||||
public class WndClass extends WndTabbed {
|
||||
|
||||
|
@ -116,19 +116,18 @@ public class WndClass extends WndTabbed {
|
|||
pos += GAP;
|
||||
}
|
||||
|
||||
RenderedText dot = PixelScene.renderText( DOT, 6 );
|
||||
BitmapText dot = PixelScene.createText( DOT, 6 );
|
||||
dot.x = MARGIN;
|
||||
dot.y = pos;
|
||||
if (dotWidth == 0) {
|
||||
dot.measure();
|
||||
dotWidth = dot.width();
|
||||
}
|
||||
add( dot );
|
||||
|
||||
BitmapTextMultiline item = PixelScene.createMultiline( items[i], 6 );
|
||||
item.x = dot.x + dotWidth;
|
||||
item.y = pos;
|
||||
item.maxWidth = (int)(WIDTH - MARGIN * 2 - dotWidth);
|
||||
item.measure();
|
||||
RenderedTextMultiline item = PixelScene.renderMultiline( items[i], 6 );
|
||||
item.maxWidth((int)(WIDTH - MARGIN * 2 - dotWidth));
|
||||
item.setPos(dot.x + dotWidth, pos);
|
||||
add( item );
|
||||
|
||||
pos += item.height();
|
||||
|
@ -169,7 +168,7 @@ public class WndClass extends WndTabbed {
|
|||
break;
|
||||
}
|
||||
|
||||
HighlightedText text = new HighlightedText( 6 );
|
||||
RenderedTextMultiline text = PixelScene.renderMultiline( 6 );
|
||||
text.text( message, WIDTH - MARGIN * 2 );
|
||||
text.setPos( MARGIN, MARGIN );
|
||||
add( text );
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HighlightedText;
|
||||
import com.watabou.noosa.BitmapTextMultiline;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.noosa.RenderedTextMultiline;
|
||||
|
||||
public class WndOptions extends Window {
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class WndOptions extends Window {
|
|||
tfTitle.measure();
|
||||
add( tfTitle );
|
||||
|
||||
HighlightedText tfMesage = new HighlightedText( 6 );
|
||||
RenderedTextMultiline tfMesage = PixelScene.renderMultiline( 6 );
|
||||
tfMesage.text(message, width - MARGIN * 2);
|
||||
tfMesage.setPos( MARGIN, tfTitle.y + tfTitle.height() + MARGIN );
|
||||
add( tfMesage );
|
||||
|
|
|
@ -21,8 +21,9 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
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.RenderedTextMultiline;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
|
||||
|
@ -47,7 +48,7 @@ public class WndTitledMessage extends Window {
|
|||
titlebar.setRect( 0, 0, width, 0 );
|
||||
add(titlebar);
|
||||
|
||||
HighlightedText text = new HighlightedText( 6 );
|
||||
RenderedTextMultiline text = PixelScene.renderMultiline( 6 );
|
||||
text.text( message, width );
|
||||
text.setPos( titlebar.left(), titlebar.bottom() + GAP );
|
||||
add( text );
|
||||
|
|
Loading…
Reference in New Issue
Block a user