v1.4.0: removed a bunch more toString methods/calls that were unneeded
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2022 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 <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.watabou.utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
@@ -146,11 +146,6 @@ public class PointF {
|
||||
public static float angle( PointF start, PointF end ) {
|
||||
return (float)Math.atan2( end.y - start.y, end.x - start.x );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "" + x + ", " + y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
|
||||
@@ -261,7 +261,7 @@ public class Badges {
|
||||
String names[] = new String[badges.size()];
|
||||
|
||||
for (Badge badge:badges) {
|
||||
names[count++] = badge.toString();
|
||||
names[count++] = badge.name();
|
||||
}
|
||||
bundle.put( BADGES, names );
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public class Burning extends Buff implements Hero.Doom {
|
||||
|
||||
if (!burnable.isEmpty()){
|
||||
Item toBurn = Random.element(burnable).detach(hero.belongings.backpack);
|
||||
GLog.w( Messages.get(this, "burnsup", Messages.capitalize(toBurn.toString())) );
|
||||
GLog.w( Messages.get(this, "burnsup", Messages.capitalize(toBurn.title())) );
|
||||
if (toBurn instanceof MysteryMeat || toBurn instanceof FrozenCarpaccio){
|
||||
ChargrilledMeat steak = new ChargrilledMeat();
|
||||
if (!steak.collect( hero.belongings.backpack )) {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Frost extends FlavourBuff {
|
||||
|
||||
if (!freezable.isEmpty()){
|
||||
Item toFreeze = Random.element(freezable).detach( hero.belongings.backpack );
|
||||
GLog.w( Messages.get(this, "freezes", toFreeze.toString()) );
|
||||
GLog.w( Messages.get(this, "freezes", toFreeze.title()) );
|
||||
if (toFreeze instanceof Potion){
|
||||
((Potion) toFreeze).shatter(hero.pos);
|
||||
} else if (toFreeze instanceof MysteryMeat){
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PinCushion extends Buff {
|
||||
public String desc() {
|
||||
String desc = Messages.get(this, "desc");
|
||||
for (Item i : items){
|
||||
desc += "\n" + i.toString();
|
||||
desc += "\n" + i.title();
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
@@ -348,15 +348,14 @@ public class Heap implements Bundlable {
|
||||
items.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
public String title(){
|
||||
switch(type){
|
||||
case FOR_SALE:
|
||||
Item i = peek();
|
||||
if (size() == 1) {
|
||||
return Messages.get(this, "for_sale", Shopkeeper.sellPrice(i), i.toString());
|
||||
return Messages.get(this, "for_sale", Shopkeeper.sellPrice(i), i.title());
|
||||
} else {
|
||||
return i.toString();
|
||||
return i.title();
|
||||
}
|
||||
case CHEST:
|
||||
return Messages.get(this, "chest");
|
||||
@@ -371,7 +370,7 @@ public class Heap implements Bundlable {
|
||||
case REMAINS:
|
||||
return Messages.get(this, "remains");
|
||||
default:
|
||||
return peek().toString();
|
||||
return peek().title();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +435,7 @@ public class Heap implements Bundlable {
|
||||
public void storeInBundle( Bundle bundle ) {
|
||||
bundle.put( POS, pos );
|
||||
bundle.put( SEEN, seen );
|
||||
bundle.put( TYPE, type.toString() );
|
||||
bundle.put( TYPE, type );
|
||||
bundle.put( ITEMS, items );
|
||||
bundle.put( HAUNTED, haunted );
|
||||
bundle.put( AUTO_EXPLORED, autoExplored );
|
||||
|
||||
@@ -424,9 +424,8 @@ public class Item implements Bundlable {
|
||||
public static void evoke( Hero hero ) {
|
||||
hero.sprite.emitter().burst( Speck.factory( Speck.EVOKE ), 5 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
public String title() {
|
||||
|
||||
String name = name();
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ItemStatusHandler<T extends Item> {
|
||||
|
||||
public void save( Bundle bundle ) {
|
||||
for (int i=0; i < items.length; i++) {
|
||||
String itemName = items[i].toString();
|
||||
String itemName = items[i].getSimpleName();
|
||||
bundle.put( itemName + PFX_LABEL, itemLabels.get( items[i] ) );
|
||||
bundle.put( itemName + PFX_KNOWN, known.contains( items[i] ) );
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class ItemStatusHandler<T extends Item> {
|
||||
for (Item item : itemsToSave){
|
||||
if (items.contains(item.getClass())){
|
||||
Class<? extends T> cls = items.get(items.indexOf(item.getClass()));
|
||||
String itemName = cls.toString();
|
||||
String itemName = cls.getSimpleName();
|
||||
bundle.put( itemName + PFX_LABEL, itemLabels.get( cls ) );
|
||||
bundle.put( itemName + PFX_KNOWN, known.contains( cls ) );
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class ItemStatusHandler<T extends Item> {
|
||||
for (Class<?extends Item> cls : clsToSave){
|
||||
if (items.contains(cls)){
|
||||
Class<? extends T> toSave = items.get(items.indexOf(cls));
|
||||
String itemName = toSave.toString();
|
||||
String itemName = toSave.getSimpleName();
|
||||
bundle.put( itemName + PFX_LABEL, itemLabels.get( toSave ) );
|
||||
bundle.put( itemName + PFX_KNOWN, known.contains( toSave ) );
|
||||
}
|
||||
@@ -116,7 +116,12 @@ public class ItemStatusHandler<T extends Item> {
|
||||
for (int i=0; i < items.length; i++) {
|
||||
|
||||
Class<? extends T> item = items[i];
|
||||
String itemName = item.toString();
|
||||
String itemName = item.getSimpleName();
|
||||
|
||||
//pre-1.4.0 saves
|
||||
if (!bundle.contains( itemName + PFX_LABEL )){
|
||||
itemName = item.toString();
|
||||
}
|
||||
|
||||
if (bundle.contains( itemName + PFX_LABEL )) {
|
||||
|
||||
@@ -137,7 +142,7 @@ public class ItemStatusHandler<T extends Item> {
|
||||
|
||||
for (Class<? extends T> item : unlabelled){
|
||||
|
||||
String itemName = item.toString();
|
||||
String itemName = item.getSimpleName();
|
||||
|
||||
int index = Random.Int( labelsLeft.size() );
|
||||
|
||||
|
||||
@@ -88,9 +88,9 @@ public abstract class KindofMisc extends EquipableItem {
|
||||
new WndOptions(new ItemSprite(this),
|
||||
Messages.get(KindofMisc.class, "unequip_title"),
|
||||
Messages.get(KindofMisc.class, "unequip_message"),
|
||||
miscs[0] == null ? "---" : Messages.titleCase(miscs[0].toString()),
|
||||
miscs[1] == null ? "---" : Messages.titleCase(miscs[1].toString()),
|
||||
miscs[2] == null ? "---" : Messages.titleCase(miscs[2].toString())) {
|
||||
miscs[0] == null ? "---" : Messages.titleCase(miscs[0].title()),
|
||||
miscs[1] == null ? "---" : Messages.titleCase(miscs[1].title()),
|
||||
miscs[2] == null ? "---" : Messages.titleCase(miscs[2].title())) {
|
||||
|
||||
@Override
|
||||
protected void onSelect(int index) {
|
||||
|
||||
@@ -231,11 +231,11 @@ public class DriedRose extends Artifact {
|
||||
desc += "\n";
|
||||
|
||||
if (weapon != null) {
|
||||
desc += "\n" + Messages.get(this, "desc_weapon", weapon.toString());
|
||||
desc += "\n" + Messages.get(this, "desc_weapon", weapon.title());
|
||||
}
|
||||
|
||||
if (armor != null) {
|
||||
desc += "\n" + Messages.get(this, "desc_armor", armor.toString());
|
||||
desc += "\n" + Messages.get(this, "desc_armor", armor.title());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ public class Ring extends KindofMisc {
|
||||
levelsToID -= levelPercent;
|
||||
if (levelsToID <= 0){
|
||||
identify();
|
||||
GLog.p( Messages.get(Ring.class, "identify", toString()) );
|
||||
GLog.p( Messages.get(Ring.class, "identify", title()) );
|
||||
Badges.validateItemLevelAquired( this );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class Notes {
|
||||
@Override
|
||||
public void storeInBundle(Bundle bundle) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put( LANDMARK, landmark.toString() );
|
||||
bundle.put( LANDMARK, landmark.name() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class Notes {
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return key.toString();
|
||||
return key.title();
|
||||
}
|
||||
|
||||
public Class<? extends Key> type(){
|
||||
|
||||
@@ -1390,7 +1390,7 @@ public class GameScene extends PixelScene {
|
||||
for (Object obj : objects){
|
||||
if (obj instanceof Hero) names.add(((Hero) obj).className().toUpperCase(Locale.ENGLISH));
|
||||
else if (obj instanceof Mob) names.add(Messages.titleCase( ((Mob)obj).name() ));
|
||||
else if (obj instanceof Heap) names.add(Messages.titleCase( ((Heap)obj).toString() ));
|
||||
else if (obj instanceof Heap) names.add(Messages.titleCase( ((Heap)obj).title() ));
|
||||
else if (obj instanceof Plant) names.add(Messages.titleCase( ((Plant) obj).name() ));
|
||||
else if (obj instanceof Trap) names.add(Messages.titleCase( ((Trap) obj).name() ));
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ public class BuffIndicator extends Component {
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(buff.toString());
|
||||
return Messages.titleCase(buff.name());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,14 +51,14 @@ public class IconTitle extends Component {
|
||||
public IconTitle( Item item ) {
|
||||
ItemSprite icon = new ItemSprite();
|
||||
icon( icon );
|
||||
label( Messages.titleCase( item.toString() ) );
|
||||
label( Messages.titleCase( item.title() ) );
|
||||
icon.view( item );
|
||||
}
|
||||
|
||||
public IconTitle( Heap heap ){
|
||||
ItemSprite icon = new ItemSprite();
|
||||
icon( icon );
|
||||
label( Messages.titleCase( heap.toString() ) );
|
||||
label( Messages.titleCase( heap.title() ) );
|
||||
icon.view( heap );
|
||||
}
|
||||
|
||||
|
||||
@@ -63,12 +63,12 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
||||
});
|
||||
|
||||
try {
|
||||
Game.version = NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleVersionString").toString();
|
||||
Game.version = NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleVersionString").description();
|
||||
} catch (Exception e) {
|
||||
Game.version = "???";
|
||||
}
|
||||
try {
|
||||
Game.versionCode = Integer.parseInt(NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleVersion").toString());
|
||||
Game.versionCode = Integer.parseInt(NSBundle.getMainBundle().getInfoDictionaryObject("CFBundleVersion").description());
|
||||
} catch (Exception e) {
|
||||
Game.versionCode = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user