From 551638f972fe25945f6677f313ded1c0d8104a4f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 27 Jan 2016 20:11:17 -0500 Subject: [PATCH] v0.3.4: moved capitalization to Messages, added title case functionality, removed Utils --- .../actors/mobs/Mob.java | 1 - .../actors/mobs/RotLasher.java | 1 - .../actors/mobs/Thief.java | 1 - .../actors/mobs/npcs/Wandmaker.java | 1 - .../shatteredpixeldungeon/items/Gold.java | 1 - .../items/TomeOfMastery.java | 2 - .../items/artifacts/Artifact.java | 5 +- .../items/artifacts/LloydsBeacon.java | 5 -- .../items/keys/IronKey.java | 2 - .../items/rings/Ring.java | 7 +-- .../items/weapon/melee/MeleeWeapon.java | 1 - .../messages/Messages.java | 53 +++++++++++++++++-- .../plants/Earthroot.java | 1 - .../shatteredpixeldungeon/plants/Plant.java | 1 - .../shatteredpixeldungeon/ui/GameLog.java | 1 - .../shatteredpixeldungeon/utils/Utils.java | 29 ---------- .../windows/IconTitle.java | 4 +- .../shatteredpixeldungeon/windows/WndBag.java | 4 +- .../windows/WndBlacksmith.java | 3 +- .../windows/WndChooseWay.java | 5 +- .../windows/WndClass.java | 4 +- .../shatteredpixeldungeon/windows/WndImp.java | 3 +- .../windows/WndInfoBuff.java | 4 +- .../windows/WndInfoItem.java | 3 +- .../windows/WndInfoMob.java | 5 +- .../windows/WndQuest.java | 4 +- .../windows/WndRanking.java | 3 +- .../windows/WndTradeItem.java | 3 +- .../windows/WndWandmaker.java | 3 +- 29 files changed, 71 insertions(+), 89 deletions(-) delete mode 100644 src/com/shatteredpixel/shatteredpixeldungeon/utils/Utils.java diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index b333fd1d2..b33b07891 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -48,7 +48,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level.Feeling; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Bundle; import com.watabou.utils.Random; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotLasher.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotLasher.java index 43ecea647..db0122389 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotLasher.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/RotLasher.java @@ -28,7 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.sprites.RotLasherSprite; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Random; import java.util.HashSet; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Thief.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Thief.java index abd1fc536..6aedb7501 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Thief.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Thief.java @@ -36,7 +36,6 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ThiefSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Bundle; import com.watabou.utils.Random; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java index 10d6ac757..5def8d789 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -40,7 +40,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.WandmakerSprite; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest; import com.shatteredpixel.shatteredpixeldungeon.windows.WndWandmaker; import com.watabou.utils.Bundle; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/Gold.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/Gold.java index ee8a5dbf1..0b4660bf7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/Gold.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/Gold.java @@ -32,7 +32,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Bundle; import com.watabou.utils.Random; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/TomeOfMastery.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/TomeOfMastery.java index 069ec5ab9..fdce8a667 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/TomeOfMastery.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/TomeOfMastery.java @@ -26,7 +26,6 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.noosa.audio.Sample; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; -import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Fury; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; @@ -36,7 +35,6 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.windows.WndChooseWay; public class TomeOfMastery extends Item { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java index 7311b9e5c..0f3272b03 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/Artifact.java @@ -29,7 +29,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.KindofMisc; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -86,8 +85,8 @@ public class Artifact extends KindofMisc { ShatteredPixelDungeon.scene().add( new WndOptions(Messages.get(Artifact.class, "unequip_title"), Messages.get(Artifact.class, "unequip_message"), - Utils.capitalize(m1.toString()), - Utils.capitalize(m2.toString())) { + Messages.titleCase(m1.toString()), + Messages.titleCase(m2.toString())) { @Override protected void onSelect(int index) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java index bf75f2718..31ef30e15 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/artifacts/LloydsBeacon.java @@ -30,10 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Invisibility; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; -import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.RotHeart; -import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.RotLasher; -import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Shopkeeper; -import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker; import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation; @@ -46,7 +42,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.Glowing; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.noosa.Game; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/keys/IronKey.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/keys/IronKey.java index 3aca9fc0b..9732805c9 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/keys/IronKey.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/keys/IronKey.java @@ -21,10 +21,8 @@ package com.shatteredpixel.shatteredpixeldungeon.items.keys; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; -import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; public class IronKey extends Key { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java index 1ecb4f8a4..2ff49ad7b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java @@ -20,8 +20,6 @@ */ package com.shatteredpixel.shatteredpixeldungeon.items.rings; -import java.util.ArrayList; - import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; @@ -35,7 +33,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.ItemStatusHandler; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.watabou.utils.Bundle; import com.watabou.utils.Random; @@ -119,8 +116,8 @@ public class Ring extends KindofMisc { ShatteredPixelDungeon.scene().add( new WndOptions(Messages.get(Ring.class, "unequip_title"), Messages.get(Ring.class, "unequip_message"), - Utils.capitalize(m1.toString()), - Utils.capitalize(m2.toString())) { + Messages.titleCase(m1.toString()), + Messages.titleCase(m2.toString())) { @Override protected void onSelect(int index) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java index 7efd4977c..c42d01769 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/items/weapon/melee/MeleeWeapon.java @@ -24,7 +24,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Random; public class MeleeWeapon extends Weapon { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java b/src/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java index 5a66d105b..a95b44b6f 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java @@ -20,8 +20,10 @@ */ package com.shatteredpixel.shatteredpixeldungeon.messages; +import java.util.Arrays; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Locale; import java.util.ResourceBundle; @@ -81,16 +83,14 @@ public class Messages { } } - public static String format( String format, Object...args ) { - return String.format( Locale.ENGLISH, format, args ); - } + /** + * Resource grabbing methods + */ public static String get(String key, Object...args){ return get(null, key, args); } - //stuffing static variables with results from this means the app needs to restart for locale changes to take effect. - //so be careful with where you're calling this, never assign its result to a static value (including enum variables) public static String get(Object o, String k, Object...args){ return get(o.getClass(), k, args); } @@ -117,5 +117,48 @@ public class Messages { else return strings.get(key.toLowerCase()); } } + + /** + * String Utility Methods + */ + + public static String format( String format, Object...args ) { + return String.format( Locale.ENGLISH, format, args ); + } + + public static String capitalize( String str ){ + return Character.toTitleCase( str.charAt( 0 ) ) + str.substring( 1 ); + } + + //Words which should not be capitalized in title case, mostly prepositions which appear ingame + //This list is not comprehensive! + private static final HashSet noCaps = new HashSet<>( + Arrays.asList(new String[]{ + //English + "a", "of", + //French + "à", "avec", "de", "du", "des", + //Portugese + "a", "de", "des", "da", "das", "do", "dos", + //German + "der", "des", + //Russian + "с", //Not an english c, looks just like it though. + }) + ); + + public static String titleCase( String str ){ + String result = ""; + //split by any unicode space character + for (String word : str.split("(?<=\\p{Zs})")){ + if (noCaps.contains(word.trim().toLowerCase())){ + result += word; + } else { + result += capitalize(word); + } + } + //first character is always capitalized. + return capitalize(result); + } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java index a0c76fd36..b40e89360 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java @@ -31,7 +31,6 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.particles.EarthParticle; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfParalyticGas; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Bundle; public class Earthroot extends Plant { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java index af7dc4480..f7e5f6251 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/plants/Plant.java @@ -41,7 +41,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.sprites.PlantSprite; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.Random; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ui/GameLog.java b/src/com/shatteredpixel/shatteredpixeldungeon/ui/GameLog.java index 709aeda0a..1c5920518 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ui/GameLog.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ui/GameLog.java @@ -28,7 +28,6 @@ import com.watabou.noosa.ui.Component; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.utils.Signal; public class GameLog extends Component implements Signal.Listener { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/utils/Utils.java b/src/com/shatteredpixel/shatteredpixeldungeon/utils/Utils.java deleted file mode 100644 index 8107e0bed..000000000 --- a/src/com/shatteredpixel/shatteredpixeldungeon/utils/Utils.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2015 Oleg Dolya - * - * Shattered Pixel Dungeon - * Copyright (C) 2014-2015 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.utils; - -public class Utils { - - public static String capitalize( String str ) { - return Character.toUpperCase( str.charAt( 0 ) ) + str.substring( 1 ); - } - -} diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java index 0b5c72958..b3c951d28 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/IconTitle.java @@ -20,6 +20,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.windows; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.noosa.Image; import com.watabou.noosa.RenderedTextMultiline; import com.watabou.noosa.ui.Component; @@ -28,7 +29,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.HealthBar; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; public class IconTitle extends Component { @@ -49,7 +49,7 @@ public class IconTitle extends Component { public IconTitle( Item item ) { ItemSprite icon = new ItemSprite(); icon( icon ); - label( Utils.capitalize( item.toString() ) ); + label( Messages.titleCase( item.toString() ) ); icon.view( item ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index fd9e9bb8d..3ec0313f3 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -41,6 +41,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon; import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant.Seed; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; @@ -48,7 +49,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot; import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.gltextures.TextureCache; import com.watabou.noosa.ColorBlock; import com.watabou.noosa.Image; @@ -113,7 +113,7 @@ public class WndBag extends WndTabbed { int slotsWidth = SLOT_SIZE * nCols + SLOT_MARGIN * (nCols - 1); int slotsHeight = SLOT_SIZE * nRows + SLOT_MARGIN * (nRows - 1); - RenderedText txtTitle = PixelScene.renderText( title != null ? title : Utils.capitalize( bag.name() ), 9 ); + RenderedText txtTitle = PixelScene.renderText( title != null ? title : Messages.titleCase( bag.name() ), 9 ); txtTitle.hardlight( TITLE_COLOR ); txtTitle.x = (int)(slotsWidth - txtTitle.width()) / 2; txtTitle.y = (int)(TITLE_HEIGHT - txtTitle.height()) / 2; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java index 486c376b8..6e67b428c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java @@ -35,7 +35,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; public class WndBlacksmith extends Window { @@ -56,7 +55,7 @@ public class WndBlacksmith extends Window { IconTitle titlebar = new IconTitle(); titlebar.icon( troll.sprite() ); - titlebar.label( Utils.capitalize( troll.name ) ); + titlebar.label( Messages.titleCase( troll.name ) ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChooseWay.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChooseWay.java index 9efd586ec..4a55fc142 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChooseWay.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndChooseWay.java @@ -27,7 +27,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.TomeOfMastery; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; 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 { @@ -51,7 +50,7 @@ public class WndChooseWay extends Window { hl.setPos( titlebar.left(), titlebar.bottom() + GAP ); add( hl ); - RedButton btnWay1 = new RedButton( Utils.capitalize( way1.title() ) ) { + RedButton btnWay1 = new RedButton( way1.title().toUpperCase() ) { @Override protected void onClick() { hide(); @@ -61,7 +60,7 @@ public class WndChooseWay extends Window { btnWay1.setRect( 0, hl.bottom() + GAP, (WIDTH - GAP) / 2, BTN_HEIGHT ); add( btnWay1 ); - RedButton btnWay2 = new RedButton( Utils.capitalize( way2.title() ) ) { + RedButton btnWay2 = new RedButton( way2.title().toUpperCase() ) { @Override protected void onClick() { hide(); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndClass.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndClass.java index d9206e882..d0dbe281d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndClass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndClass.java @@ -27,8 +27,6 @@ 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.utils.Utils; -import com.watabou.noosa.RenderedText; import com.watabou.noosa.RenderedTextMultiline; public class WndClass extends WndTabbed { @@ -51,7 +49,7 @@ public class WndClass extends WndTabbed { tabPerks = new PerksTab(); add( tabPerks ); - Tab tab = new RankingTab( Utils.capitalize( cl.title() ), tabPerks ); + Tab tab = new RankingTab( cl.title().toUpperCase(), tabPerks ); tab.setSize( TAB_WIDTH, tabHeight() ); add( tab ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java index 710c04ad0..825b8e164 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndImp.java @@ -30,7 +30,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.noosa.RenderedTextMultiline; public class WndImp extends Window { @@ -45,7 +44,7 @@ public class WndImp extends Window { IconTitle titlebar = new IconTitle(); titlebar.icon( new ItemSprite( tokens.image(), null ) ); - titlebar.label( Utils.capitalize( tokens.name() ) ); + titlebar.label( Messages.titleCase( tokens.name() ) ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoBuff.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoBuff.java index 4feb595d4..09310b1c7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoBuff.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoBuff.java @@ -22,9 +22,9 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.gltextures.SmartTexture; import com.watabou.gltextures.TextureCache; import com.watabou.noosa.Image; @@ -52,7 +52,7 @@ public class WndInfoBuff extends Window { buffIcon.frame( film.get(buff.icon()) ); titlebar.icon( buffIcon ); - titlebar.label( Utils.capitalize(buff.toString()), Window.TITLE_COLOR ); + titlebar.label( Messages.titleCase(buff.toString()), Window.TITLE_COLOR ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java index 8aea5b582..629ac5880 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoItem.java @@ -32,7 +32,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.noosa.RenderedTextMultiline; public class WndInfoItem extends Window { @@ -115,7 +114,7 @@ public class WndInfoItem extends Window { IconTitle titlebar = new IconTitle(); titlebar.icon( new ItemSprite( image, glowing ) ); - titlebar.label( Utils.capitalize( title ), titleColor ); + titlebar.label( Messages.titleCase( title ), titleColor ); titlebar.setRect( 0, 0, width, 0 ); add( titlebar ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java index 7736acd7f..28fbea3c0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoMob.java @@ -20,7 +20,7 @@ */ package com.shatteredpixel.shatteredpixeldungeon.windows; -import com.watabou.noosa.BitmapText; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.watabou.noosa.RenderedText; import com.watabou.noosa.ui.Component; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; @@ -28,7 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.HealthBar; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; public class WndInfoMob extends WndTitledMessage { @@ -58,7 +57,7 @@ public class WndInfoMob extends WndTitledMessage { public MobTitle( Mob mob ) { - name = PixelScene.renderText( Utils.capitalize( mob.name ), 9 ); + name = PixelScene.renderText( Messages.titleCase( mob.name ), 9 ); name.hardlight( TITLE_COLOR ); add( name ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndQuest.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndQuest.java index 6df1a315c..d690697ab 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndQuest.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndQuest.java @@ -21,11 +21,11 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.NPC; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; public class WndQuest extends WndTitledMessage { public WndQuest( NPC questgiver, String text ) { - super( questgiver.sprite(), Utils.capitalize( questgiver.name ), text ); + super( questgiver.sprite(), Messages.titleCase( questgiver.name ), text ); } } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java index 56f89fee3..ab9c69336 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java @@ -45,7 +45,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.ScrollPane; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; public class WndRanking extends WndTabbed { @@ -321,7 +320,7 @@ public class WndRanking extends WndTabbed { name.x = slot.right() + 2; name.y = y + (height - name.baseLine()) / 2; - String str = Utils.capitalize( item.name() ); + String str = Messages.titleCase( item.name() ); name.text( str ); if (name.width() > width - name.x) { do { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java index d561458f7..3c57b9ccf 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTradeItem.java @@ -36,7 +36,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.noosa.RenderedTextMultiline; public class WndTradeItem extends Window { @@ -200,7 +199,7 @@ public class WndTradeItem extends Window { titlebar.icon( new ItemSprite( item ) ); titlebar.label( forSale ? Messages.get(this, "sale", item.toString(), price( item ) ) : - Utils.capitalize( item.toString() ) ); + Messages.titleCase( item.toString() ) ); titlebar.setRect( 0, 0, WIDTH, 0 ); add( titlebar ); diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java index d69b02344..c489f567d 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndWandmaker.java @@ -33,7 +33,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; -import com.shatteredpixel.shatteredpixeldungeon.utils.Utils; import com.watabou.noosa.RenderedTextMultiline; public class WndWandmaker extends Window { @@ -48,7 +47,7 @@ public class WndWandmaker extends Window { IconTitle titlebar = new IconTitle(); titlebar.icon(new ItemSprite(item.image(), null)); - titlebar.label(Utils.capitalize(item.name())); + titlebar.label(Messages.titleCase(item.name())); titlebar.setRect(0, 0, WIDTH, 0); add( titlebar );