From b4390924430610cae26000bc27722087320d27b2 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 11 Oct 2019 19:56:54 -0400 Subject: [PATCH] v0.7.5b: removed bitmaptextmultiline and various unused related code --- .../watabou/noosa/BitmapTextMultiline.java | 324 ------------------ android/src/main/assets/font1x.png | Bin 2238 -> 0 bytes android/src/main/assets/font2x.png | Bin 2887 -> 0 bytes .../scenes/PixelScene.java | 79 +---- .../ui/HighlightedText.java | 81 ----- 5 files changed, 1 insertion(+), 483 deletions(-) delete mode 100644 SPD-classes/src/main/java/com/watabou/noosa/BitmapTextMultiline.java delete mode 100644 android/src/main/assets/font1x.png delete mode 100644 android/src/main/assets/font2x.png delete mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/HighlightedText.java diff --git a/SPD-classes/src/main/java/com/watabou/noosa/BitmapTextMultiline.java b/SPD-classes/src/main/java/com/watabou/noosa/BitmapTextMultiline.java deleted file mode 100644 index d6f949ddc..000000000 --- a/SPD-classes/src/main/java/com/watabou/noosa/BitmapTextMultiline.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2015 Oleg Dolya - * - * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 Evan Debenham - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -package com.watabou.noosa; - -import com.watabou.glwrap.Quad; -import com.watabou.utils.PointF; -import com.watabou.utils.RectF; - -import java.util.ArrayList; -import java.util.regex.Pattern; - -public class BitmapTextMultiline extends BitmapText { - - public int maxWidth = Integer.MAX_VALUE; - - protected static final Pattern PARAGRAPH = Pattern.compile( "\n" ); - protected static final Pattern WORD = Pattern.compile( "\\s+" ); - - protected float spaceSize; - - public int nLines = 0; - - public boolean[] mask; - - public BitmapTextMultiline( Font font ) { - this( "", font ); - } - - public BitmapTextMultiline( String text, Font font ) { - super( text, font ); - spaceSize = font.width( font.get( ' ' ) ); - } - - @Override - protected void updateVertices() { - - if (text == null) { - text = ""; - } - - quads = Quad.createSet( text.length() ); - realLength = 0; - - // This object controls lines breaking - SymbolWriter writer = new SymbolWriter(); - - // Word size - PointF metrics = new PointF(); - - String paragraphs[] = PARAGRAPH.split( text ); - - // Current character (used in masking) - int pos = 0; - - for (int i=0; i < paragraphs.length; i++) { - - String[] words = WORD.split( paragraphs[i] ); - - for (int j=0; j < words.length; j++) { - - String word = words[j]; - if (word.length() == 0) { - // This case is possible when there are - // several spaces coming along - continue; - } - - - getWordMetrics( word, metrics ); - writer.addSymbol( metrics.x, metrics.y ); - - int length = word.length(); - float shift = 0; // Position in pixels relative to the beginning of the word - - for (int k=0; k < length; k++) { - RectF rect = font.get( word.charAt( k ) ); - - float w = font.width( rect ); - float h = font.height( rect ); - - if (mask == null || mask[pos]) { - vertices[0] = writer.x + shift; - vertices[1] = writer.y; - - vertices[2] = rect.left; - vertices[3] = rect.top; - - vertices[4] = writer.x + shift + w; - vertices[5] = writer.y; - - vertices[6] = rect.right; - vertices[7] = rect.top; - - vertices[8] = writer.x + shift + w; - vertices[9] = writer.y + h; - - vertices[10] = rect.right; - vertices[11] = rect.bottom; - - vertices[12] = writer.x + shift; - vertices[13] = writer.y + h; - - vertices[14] = rect.left; - vertices[15] = rect.bottom; - - quads.put( vertices ); - realLength++; - } - - shift += w + font.tracking; - - pos++; - } - - writer.addSpace( spaceSize ); - } - - writer.newLine( 0, font.lineHeight ); - } - - nLines = writer.nLines(); - - dirty = false; - } - - private void getWordMetrics( String word, PointF metrics ) { - - float w = 0; - float h = 0; - - int length = word.length(); - for (int i=0; i < length; i++) { - - RectF rect = font.get( word.charAt( i ) ); - w += font.width( rect ) + (w > 0 ? font.tracking : 0); - h = Math.max( h, font.height( rect ) ); - } - - metrics.set( w, h ); - } - - @Override - public void measure() { - - SymbolWriter writer = new SymbolWriter(); - - PointF metrics = new PointF(); - - String paragraphs[] = PARAGRAPH.split( text ); - - for (int i=0; i < paragraphs.length; i++) { - - String[] words = WORD.split( paragraphs[i] ); - - for (int j=0; j < words.length; j++) { - - if (j > 0) { - writer.addSpace( spaceSize ); - } - String word = words[j]; - if (word.length() == 0) { - continue; - } - - getWordMetrics( word, metrics ); - writer.addSymbol( metrics.x, metrics.y ); - } - - writer.newLine( 0, font.lineHeight ); - } - - width = writer.width; - height = writer.height; - - nLines = writer.nLines(); - } - - @Override - public float baseLine() { - return (height - font.lineHeight + font.baseLine) * scale.y; - } - - private class SymbolWriter { - - public float width = 0; - public float height = 0; - - public int nLines = 0; - - public float lineWidth = 0; - public float lineHeight = 0; - - public float x = 0; - public float y = 0; - - public void addSymbol( float w, float h ) { - if (lineWidth > 0 && lineWidth + font.tracking + w > maxWidth / scale.x) { - newLine( w, h ); - } else { - - x = lineWidth; - - lineWidth += (lineWidth > 0 ? font.tracking : 0) + w; - if (h > lineHeight) { - lineHeight = h; - } - } - } - - public void addSpace( float w ) { - if (lineWidth > 0 && lineWidth + font.tracking + w > maxWidth / scale.x) { - newLine( 0, 0 ); - } else { - - x = lineWidth; - lineWidth += (lineWidth > 0 ? font.tracking : 0) + w; - } - } - - public void newLine( float w, float h ) { - - height += lineHeight; - if (width < lineWidth) { - width = lineWidth; - } - - lineWidth = w; - lineHeight = h; - - x = 0; - y = height; - - nLines++; - } - - public int nLines() { - return x == 0 ? nLines : nLines+1; - } - } - - public class LineSplitter { - - private ArrayList lines; - - private StringBuilder curLine; - private float curLineWidth; - - private PointF metrics = new PointF(); - - private void newLine( String str, float width ) { - BitmapText txt = new BitmapText( curLine.toString(), font ); - txt.scale.set( scale.x ); - lines.add( txt ); - - curLine = new StringBuilder( str ); - curLineWidth = width; - } - - private void append( String str, float width ) { - curLineWidth += (curLineWidth > 0 ? font.tracking : 0) + width; - curLine.append( str ); - } - - public ArrayList split() { - - lines = new ArrayList<>(); - - curLine = new StringBuilder(); - curLineWidth = 0; - - String paragraphs[] = PARAGRAPH.split( text ); - - for (int i=0; i < paragraphs.length; i++) { - - String[] words = WORD.split( paragraphs[i] ); - - for (int j=0; j < words.length; j++) { - - String word = words[j]; - if (word.length() == 0) { - continue; - } - - getWordMetrics( word, metrics ); - - if (curLineWidth > 0 && curLineWidth + font.tracking + metrics.x > maxWidth / scale.x) { - newLine( word, metrics.x ); - } else { - append( word, metrics.x ); - } - - if (curLineWidth > 0 && curLineWidth + font.tracking + spaceSize > maxWidth / scale.x) { - newLine( "", 0 ); - } else { - append( " ", spaceSize ); - } - } - - newLine( "", 0 ); - } - - return lines; - } - } -} \ No newline at end of file diff --git a/android/src/main/assets/font1x.png b/android/src/main/assets/font1x.png deleted file mode 100644 index 7a8e7e4bc439fcff94ebe9eb0ee90db2ceea3658..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2238 zcmV;v2toIWP)18FYH{Rvv-3T7&ICXXZBlK+jiUF|1gR$ zy5d>C00)`mL7&-Z&{x%FS_YSN>zdX}ht@bqlPa^aU8GQeC(YNXx?Q+h^Ng=%sw|s} zIm*rom$7<@qmMSH0NNA=JDMB z00YLL;V6ay)}W2P&cF8tgV9E*VQebfRz=erVRVTGVeAcHj;LU=8NnH2+iPert7+}r zesa3|6Q6r#gajU4X$vHqrHKbc7azKmu2oGby5w44*tG*lS(EGz;J z;z0nB0l;vpnGpz@?T=VQ0472J2;vz401JS?kmx&nVSyRCE(3sx2mlulx|u>Y9$oiU z`nzRlZ{Cwkz_^n?>b!H#Id#gr)%CCPolE@6YMMH=bn(PgI|)HdarcZjKrRptN!k#; zp$u_u_k(avj-v2|n3mDczX8YnqP2a#HV!L<4Ig}C$+(@hyBN;*i&#?Heh%k7v`Qg> zK@u2_gY%rO#NE;NvA<&u8(I#-5YfI4q`sF27R4_Dh-WR+h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ENEm|t*=q`WsIX!vcr`zKfaO169onB~40`(~4YKa-VbmGKhGx4l}#B@%Y zZk>>UO(ffREr<6letfC*qrjma>d=zpF7j7J5k!t%DDEM>WgJj+*_#UD547ej4;fu5sGxpbVJBUf=I-zXJ)j=Rtvry$mTsLfV{lHJh@k1FAmn~p6=H|Ib#Yb_R)h@ zQLn7M3423=6Q65q)Z4T)#(02n+J`UlzW)yNODf$jh;Hmoi;Y6g;rkqFyN#JENL4F* z_7*3wc05f@AA7w`F?Q>vxT^fvQ_yJ@XLM`1v|t6vomt~$$h)b)hsR|H!e(Cp?|4V7 g6EEOc@c-Hn;%j?6+41e)8h^aT2Il(Z2VElm3xww7^8f$< diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java index 87510fb99..d16f5e32d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java @@ -33,7 +33,6 @@ import com.watabou.glwrap.Blending; import com.watabou.input.PointerEvent; import com.watabou.noosa.BitmapText; import com.watabou.noosa.BitmapText.Font; -import com.watabou.noosa.BitmapTextMultiline; import com.watabou.noosa.Camera; import com.watabou.noosa.ColorBlock; import com.watabou.noosa.Game; @@ -64,11 +63,8 @@ public class PixelScene extends Scene { public static Camera uiCamera; - //stylized pixel font + //stylized 3x5 bitmapped pixel font. Only latin characters supported. public static BitmapText.Font pixelFont; - //These represent various mipmaps of the same font - public static BitmapText.Font font1x; - public static BitmapText.Font font2x; @Override public void create() { @@ -116,23 +112,7 @@ public class PixelScene extends Scene { BitmapCache.get( Assets.PIXELFONT), 0x00000000, BitmapText.Font.LATIN_FULL ); pixelFont.baseLine = 6; pixelFont.tracking = -1; - - //Fonts disabled to save memory (~1mb of texture data just sitting there unused) - //uncomment if you wish to enable these again. - // 9x15 (18) - /*font1x = Font.colorMarked( - BitmapCache.get( Assets.FONT1X), 22, 0x00000000, BitmapText.Font.LATIN_FULL ); - font1x.baseLine = 17; - font1x.tracking = -2; - font1x.texture.filter(Texture.LINEAR, Texture.LINEAR); - - //font1x double scaled - font2x = Font.colorMarked( - BitmapCache.get( Assets.FONT2X), 44, 0x00000000, BitmapText.Font.LATIN_FULL ); - font2x.baseLine = 38; - font2x.tracking = -4; - font2x.texture.filter(Texture.LINEAR, Texture.NEAREST);*/ } //set up the texture size which rendered text will use for any new glyphs. @@ -187,63 +167,6 @@ public class PixelScene extends Scene { PointerEvent.clearListeners(); } - public static BitmapText.Font font; - public static float scale; - - public static void chooseFont( float size ) { - chooseFont( size, defaultZoom ); - } - - public static void chooseFont( float size, float zoom ) { - - float pt = size * zoom; - - if (pt >= 25) { - - font = font2x; - scale = pt / 38f; - - } else if (pt >= 12) { - - font = font1x; - scale = pt / 19f; - - } else { - font = pixelFont; - scale = 1f; - } - - scale /= zoom; - } - - public static BitmapText createText( float size ) { - return createText( null, size ); - } - - public static BitmapText createText( String text, float size ) { - - chooseFont( size ); - - BitmapText result = new BitmapText( text, font ); - result.scale.set( scale ); - - return result; - } - - public static BitmapTextMultiline createMultiline( float size ) { - return createMultiline( null, size ); - } - - public static BitmapTextMultiline createMultiline( String text, float size ) { - - chooseFont( size ); - - BitmapTextMultiline result = new BitmapTextMultiline( text, font ); - result.scale.set( scale ); - - return result; - } - public static RenderedTextBlock renderTextBlock(int size ){ return renderTextBlock("", size); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/HighlightedText.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/HighlightedText.java deleted file mode 100644 index 50b3989fc..000000000 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/HighlightedText.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2015 Oleg Dolya - * - * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 Evan Debenham - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see - */ - -package com.shatteredpixel.shatteredpixeldungeon.ui; - -import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; -import com.watabou.noosa.BitmapTextMultiline; -import com.watabou.noosa.ui.Component; -import com.watabou.utils.Highlighter; - -public class HighlightedText extends Component { - - protected BitmapTextMultiline normal; - protected BitmapTextMultiline highlighted; - - protected int nColor = 0xFFFFFF; - protected int hColor = 0xFFFF44; - - public HighlightedText( float size ) { - normal = PixelScene.createMultiline( size ); - add( normal ); - - highlighted = PixelScene.createMultiline( size ); - add( highlighted ); - - setColor( 0xFFFFFF, 0xFFFF44 ); - } - - @Override - protected void layout() { - normal.x = highlighted.x = x; - normal.y = highlighted.y = y; - } - - public void text( String value, int maxWidth ) { - Highlighter hl = new Highlighter( value ); - - normal.text( hl.text ); - normal.maxWidth = maxWidth; - normal.measure(); - - if (hl.isHighlighted()) { - normal.mask = hl.inverted(); - - highlighted.text( hl.text ); - highlighted.maxWidth = maxWidth; - highlighted.measure(); - - highlighted.mask = hl.mask; - highlighted.visible = true; - } else { - highlighted.visible = false; - } - - width = normal.width(); - height = normal.height(); - } - - public void setColor( int n, int h ) { - normal.hardlight( n ); - highlighted.hardlight( h ); - } -} \ No newline at end of file