v1.2.0: added hover tooltips to buttons!
This commit is contained in:
@@ -35,6 +35,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.LiquidMetal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Recipe;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.AlchemistsToolkit;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.darts.Dart;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Journal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
@@ -231,6 +232,11 @@ public class AlchemyScene extends PixelScene {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Document.ALCHEMY_GUIDE.title());
|
||||
}
|
||||
};
|
||||
btnGuide.setRect(0, 0, 20, 20);
|
||||
add(btnGuide);
|
||||
|
||||
@@ -391,6 +391,10 @@ public class GameScene extends PixelScene {
|
||||
log.newLine();
|
||||
add( log );
|
||||
|
||||
if (uiSize > 0){
|
||||
bringToFront(status);
|
||||
}
|
||||
|
||||
toolbar = new Toolbar();
|
||||
toolbar.camera = uiCamera;
|
||||
add( toolbar );
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.StyledButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndChallenges;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndHeroInfo;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.input.PointerEvent;
|
||||
@@ -142,6 +143,11 @@ public class HeroSelectScene extends PixelScene {
|
||||
super.onClick();
|
||||
ShatteredPixelDungeon.scene().addToFront(new WndHeroInfo(GamesInProgress.selectedClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "hero_info"));
|
||||
}
|
||||
};
|
||||
infoButton.visible = false;
|
||||
infoButton.setSize(21, 21);
|
||||
@@ -184,6 +190,11 @@ public class HeroSelectScene extends PixelScene {
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndChallenges.class, "title"));
|
||||
}
|
||||
};
|
||||
challengeButton.setRect(heroBtnleft + 16, Camera.main.height-HeroBtn.HEIGHT-16, 21, 21);
|
||||
challengeButton.visible = false;
|
||||
|
||||
@@ -40,7 +40,7 @@ import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Music;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Button;
|
||||
import com.watabou.utils.GameMath;
|
||||
|
||||
public class RankingsScene extends PixelScene {
|
||||
|
||||
@@ -38,7 +38,7 @@ import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Button;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.Image;
|
||||
|
||||
@@ -100,6 +102,12 @@ public class ActionIndicator extends Tag {
|
||||
action.doAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
//TODO each special action should probably have its own title
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "tag_action"));
|
||||
}
|
||||
|
||||
public static void setAction(Action action){
|
||||
ActionIndicator.action = action;
|
||||
updateIcon();
|
||||
|
||||
@@ -25,8 +25,10 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.utils.Random;
|
||||
@@ -179,8 +181,13 @@ public class AttackIndicator extends Tag {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void target( Char target ) {
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "tag_attack"));
|
||||
}
|
||||
|
||||
public static void target(Char target ) {
|
||||
synchronized (instance) {
|
||||
instance.lastTarget = (Mob) target;
|
||||
instance.updateImage();
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndBadge;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
@@ -152,6 +151,11 @@ public class BadgesGrid extends Component {
|
||||
Sample.INSTANCE.play( Assets.Sounds.CLICK, 0.7f, 0.7f, 1.2f );
|
||||
Game.scene().add( new WndBadge( badge, unlocked ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return badge.desc();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
@@ -283,6 +284,11 @@ public class BuffIndicator extends Component {
|
||||
protected void onPointerUp() {
|
||||
//don't affect buff color
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(buff.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void refreshHero() {
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* 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.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.input.KeyBindings;
|
||||
import com.watabou.input.KeyEvent;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.Signal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Button extends Component {
|
||||
|
||||
public static float longClick = 0.5f;
|
||||
|
||||
protected PointerArea hotArea;
|
||||
protected Tooltip hoverTip;
|
||||
|
||||
protected boolean pressed;
|
||||
protected float pressTime;
|
||||
protected boolean processed;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
hotArea = new PointerArea( 0, 0, 0, 0 ) {
|
||||
@Override
|
||||
protected void onPointerDown( PointerEvent event ) {
|
||||
pressed = true;
|
||||
pressTime = 0;
|
||||
processed = false;
|
||||
Button.this.onPointerDown();
|
||||
}
|
||||
@Override
|
||||
protected void onPointerUp( PointerEvent event ) {
|
||||
pressed = false;
|
||||
Button.this.onPointerUp();
|
||||
}
|
||||
@Override
|
||||
protected void onClick( PointerEvent event ) {
|
||||
if (!processed) {
|
||||
Button.this.onClick();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHoverStart(PointerEvent event) {
|
||||
String text = hoverText();
|
||||
if (text != null){
|
||||
if (keyAction() != null){
|
||||
ArrayList<Integer> bindings = KeyBindings.getBoundKeysForAction(keyAction());
|
||||
if (!bindings.isEmpty()){
|
||||
text += " _(" + KeyBindings.getKeyName(bindings.get(0)) + ")_";
|
||||
}
|
||||
}
|
||||
hoverTip = new Tooltip(text, 80);
|
||||
Button.this.parent.addToFront(hoverTip);
|
||||
hoverTip.camera = camera();
|
||||
alignTooltip(hoverTip);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHoverEnd(PointerEvent event) {
|
||||
killTooltip();
|
||||
}
|
||||
};
|
||||
add( hotArea );
|
||||
|
||||
KeyEvent.addKeyListener( keyListener = new Signal.Listener<KeyEvent>() {
|
||||
@Override
|
||||
public boolean onSignal ( KeyEvent event ) {
|
||||
if ( active && event.pressed && KeyBindings.getActionForKey( event ) == keyAction()){
|
||||
onClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Signal.Listener<KeyEvent> keyListener;
|
||||
|
||||
public GameAction keyAction(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
hotArea.active = visible;
|
||||
|
||||
if (pressed) {
|
||||
if ((pressTime += Game.elapsed) >= longClick) {
|
||||
pressed = false;
|
||||
if (onLongClick()) {
|
||||
|
||||
hotArea.reset();
|
||||
processed = true;
|
||||
onPointerUp();
|
||||
|
||||
Game.vibrate( 50 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void onPointerDown() {}
|
||||
protected void onPointerUp() {}
|
||||
protected void onClick() {}
|
||||
protected boolean onLongClick() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String hoverText() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO might be nice for more flexibility here
|
||||
private void alignTooltip( Tooltip tip ){
|
||||
tip.setPos(x, y-tip.height()-1);
|
||||
Camera cam = camera();
|
||||
//shift left if there's no room on the right
|
||||
if (tip.right() > (cam.width+cam.scroll.x)){
|
||||
tip.setPos(tip.left() - (tip.right() - (cam.width+cam.scroll.x)), tip.top());
|
||||
}
|
||||
//move to the bottom if there's no room on top
|
||||
if (tip.top() < 0){
|
||||
tip.setPos(tip.left(), bottom()+1);
|
||||
}
|
||||
}
|
||||
|
||||
public void killTooltip(){
|
||||
if (hoverTip != null){
|
||||
hoverTip.killAndErase();
|
||||
hoverTip = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
hotArea.x = x;
|
||||
hotArea.y = y;
|
||||
hotArea.width = width;
|
||||
hotArea.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void destroy () {
|
||||
super.destroy();
|
||||
KeyEvent.removeKeyListener( keyListener );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,9 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
@@ -117,4 +119,9 @@ public class DangerIndicator extends Tag {
|
||||
if (Dungeon.hero.curAction == null) Camera.main.panTo(target.sprite.center(), 5f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "tag_danger"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.TitleScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.watabou.noosa.Game;
|
||||
|
||||
public class ExitButton extends IconButton {
|
||||
@@ -42,4 +44,9 @@ public class ExitButton extends IconButton {
|
||||
ShatteredPixelDungeon.switchNoFade( TitleScene.class );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "back"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
|
||||
public class IconButton extends Button {
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.MagicalHolster;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.PotionBandolier;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.ScrollHolder;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.VelvetPouch;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
@@ -551,6 +552,10 @@ public class InventoryPane extends Component {
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(bag.name());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
|
||||
public class ItemSlot extends Button {
|
||||
|
||||
@@ -274,4 +273,10 @@ public class ItemSlot extends Button {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
if (item != null) return Messages.titleCase(item.name());
|
||||
else return super.hoverText();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.watabou.input.GameAction;
|
||||
|
||||
public class LootIndicator extends Tag {
|
||||
|
||||
@@ -26,17 +26,18 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndGame;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
|
||||
public class MenuPane extends Component {
|
||||
@@ -235,6 +236,10 @@ public class MenuPane extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "journal"));
|
||||
}
|
||||
}
|
||||
|
||||
private static class MenuButton extends Button {
|
||||
@@ -279,5 +284,15 @@ public class MenuPane extends Component {
|
||||
protected void onClick() {
|
||||
GameScene.show( new WndGame() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameAction keyAction() {
|
||||
return GameAction.BACK;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "menu"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.watabou.utils.PathFinder;
|
||||
|
||||
public class QuickSlotButton extends Button {
|
||||
@@ -118,6 +118,15 @@ public class QuickSlotButton extends Button {
|
||||
protected void onPointerUp() {
|
||||
sprite.resetColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
if (item == null){
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "quickslot_" + (slotNum+1)));
|
||||
} else {
|
||||
return super.hoverText();
|
||||
}
|
||||
}
|
||||
};
|
||||
slot.showExtraInfo( false );
|
||||
add( slot );
|
||||
@@ -164,6 +173,15 @@ public class QuickSlotButton extends Button {
|
||||
return super.keyAction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
if (slot.item == null){
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "quickslot_" + (slotNum+1)));
|
||||
} else {
|
||||
return super.hoverText();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
|
||||
@@ -23,7 +23,9 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.Image;
|
||||
|
||||
@@ -68,6 +70,11 @@ public class ResumeIndicator extends Tag {
|
||||
Dungeon.hero.resume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "tag_resume"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!Dungeon.hero.isAlive())
|
||||
|
||||
@@ -28,27 +28,25 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CircleArc;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndGame;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndHero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.input.KeyBindings;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.ColorMath;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StatusPane extends Component {
|
||||
|
||||
private NinePatch bg;
|
||||
@@ -104,6 +102,11 @@ public class StatusPane extends Component {
|
||||
public GameAction keyAction() {
|
||||
return SPDAction.HERO_INFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "hero_info"));
|
||||
}
|
||||
};
|
||||
add(heroInfo);
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
|
||||
//simple button which support a background chrome, text, and an icon.
|
||||
public class StyledButton extends Button {
|
||||
|
||||
@@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
|
||||
public class Tag extends Button {
|
||||
|
||||
|
||||
@@ -26,23 +26,16 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.InventoryScroll;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfMetamorphosis;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndInfoTalent;
|
||||
import com.watabou.gltextures.SmartTexture;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.TextureFilm;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.watabou.utils.Callback;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
@@ -230,7 +223,12 @@ public class TalentButton extends Button {
|
||||
bg.resetColor();
|
||||
}
|
||||
|
||||
public void enable( boolean value ) {
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(talent.title());
|
||||
}
|
||||
|
||||
public void enable(boolean value ) {
|
||||
active = value;
|
||||
icon.alpha( value ? 1.0f : 0.3f );
|
||||
bg.alpha( value ? 1.0f : 0.3f );
|
||||
|
||||
@@ -108,6 +108,10 @@ public class TalentsPane extends ScrollPane {
|
||||
} else {
|
||||
blockText = null;
|
||||
}
|
||||
|
||||
for (TalentTierPane p : panes){
|
||||
content.bringToFront(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTerrainTilemap;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndKeyBindings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuickBag;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.Camera;
|
||||
@@ -94,7 +95,12 @@ public class Toolbar extends Component {
|
||||
public GameAction keyAction() {
|
||||
return SPDAction.WAIT;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "wait"));
|
||||
}
|
||||
|
||||
protected boolean onLongClick() {
|
||||
if (!GameScene.cancel()) {
|
||||
examining = false;
|
||||
@@ -133,6 +139,11 @@ public class Toolbar extends Component {
|
||||
public GameAction keyAction() {
|
||||
return SPDAction.SEARCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "search"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onLongClick() {
|
||||
@@ -159,6 +170,11 @@ public class Toolbar extends Component {
|
||||
public GameAction keyAction() {
|
||||
return SPDAction.INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "inventory"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onLongClick() {
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.GameMath;
|
||||
|
||||
public class Tooltip extends Component {
|
||||
|
||||
//tooltips require .5 seconds to appear, fade in over .1 second
|
||||
//they then persist until none are visible for .5 seconds or more
|
||||
private static float tooltipAlpha = -5f;
|
||||
private static float lastUsedTime = -1;
|
||||
|
||||
private NinePatch bg;
|
||||
private RenderedTextBlock text;
|
||||
|
||||
public Tooltip(String msg, int maxWidth){
|
||||
super();
|
||||
text.text(msg, maxWidth);
|
||||
layout();
|
||||
|
||||
if (lastUsedTime != -1){
|
||||
float elapsed = Game.timeTotal - lastUsedTime;
|
||||
if (elapsed >= 0.5f || tooltipAlpha < 1f){
|
||||
tooltipAlpha = -5f;
|
||||
}
|
||||
lastUsedTime = Game.timeTotal;
|
||||
}
|
||||
bg.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
||||
text.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
|
||||
bg = Chrome.get(Chrome.Type.TOAST_TR);
|
||||
add(bg);
|
||||
|
||||
text = PixelScene.renderTextBlock(6);
|
||||
add(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void update() {
|
||||
super.update();
|
||||
tooltipAlpha = Math.min(1f, tooltipAlpha + 10f*Game.elapsed);
|
||||
lastUsedTime = Game.timeTotal;
|
||||
|
||||
bg.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
||||
text.alpha(GameMath.gate(0, tooltipAlpha, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
|
||||
text.setPos(x + bg.marginLeft(), y + bg.marginTop());
|
||||
bg.x = x;
|
||||
bg.y = y;
|
||||
bg.size(text.width()+bg.marginHor(), text.height()+bg.marginVer());
|
||||
|
||||
width = bg.width;
|
||||
height = bg.height;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -380,7 +380,11 @@ public class WndBag extends WndTabbed {
|
||||
|
||||
this.bag = bag;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(bag.name());
|
||||
}
|
||||
}
|
||||
|
||||
public static class Placeholder extends Item {
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Button;
|
||||
import com.watabou.utils.Bundle;
|
||||
import com.watabou.utils.FileUtils;
|
||||
|
||||
|
||||
@@ -149,6 +149,12 @@ public class WndHero extends WndTabbed {
|
||||
ShatteredPixelDungeon.scene().addToFront(new WndHeroInfo(hero.heroClass));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndKeyBindings.class, "hero_info"));
|
||||
}
|
||||
|
||||
};
|
||||
infoButton.setRect(title.right(), 0, 16, 16);
|
||||
add(infoButton);
|
||||
|
||||
@@ -46,7 +46,7 @@ import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Group;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Button;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -45,7 +45,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Button;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.DeviceCompat;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Button;
|
||||
import com.watabou.utils.RectF;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -153,6 +153,8 @@ public class WndTabbed extends Window {
|
||||
protected void select( boolean value ) {
|
||||
|
||||
active = !(selected = value);
|
||||
|
||||
if (!active) killTooltip();
|
||||
|
||||
if (bg != null) {
|
||||
remove( bg );
|
||||
|
||||
Reference in New Issue
Block a user