Merging 1.9.1 source: ui changes (plus wndchooseway)

This commit is contained in:
Evan Debenham
2015-11-10 03:19:38 -05:00
parent e35573883b
commit 83d492440e
9 changed files with 214 additions and 144 deletions
@@ -20,9 +20,6 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.ui;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.watabou.input.Keys;
import com.watabou.input.Keys.Key;
import com.watabou.input.Touchscreen.Touch;
@@ -158,61 +155,4 @@ public class Window extends Group implements Signal.Listener<Key> {
public void onMenuPressed() {
}
protected static class Highlighter {
private static final Pattern HIGHLIGHTER = Pattern.compile( "_(.*?)_" );
private static final Pattern STRIPPER = Pattern.compile( "[ \n]" );
public String text;
public boolean[] mask;
public Highlighter( String text ) {
String stripped = STRIPPER.matcher( text ).replaceAll( "" );
mask = new boolean[stripped.length()];
Matcher m = HIGHLIGHTER.matcher( stripped );
int pos = 0;
int lastMatch = 0;
while (m.find()) {
pos += (m.start() - lastMatch);
int groupLen = m.group( 1 ).length();
for (int i=pos; i < pos + groupLen; i++) {
mask[i] = true;
}
pos += groupLen;
lastMatch = m.end();
}
m.reset( text );
StringBuffer sb = new StringBuffer();
while (m.find()) {
m.appendReplacement( sb, m.group( 1 ) );
}
m.appendTail( sb );
this.text = sb.toString();
}
public boolean[] inverted() {
boolean[] result = new boolean[mask.length];
for (int i=0; i < result.length; i++) {
result[i] = !mask[i];
}
return result;
}
public boolean isHighlighted() {
for (int i=0; i < mask.length; i++) {
if (mask[i]) {
return true;
}
}
return false;
}
}
}