v1.3.2: fixed various inconsistencies with controller tooltip prompts

This commit is contained in:
Evan Debenham
2022-07-26 14:52:18 -04:00
parent cad7c0eb87
commit 3ae14078d8
9 changed files with 61 additions and 12 deletions
@@ -83,11 +83,17 @@ public class Button extends Component {
protected void onHoverStart(PointerEvent event) {
String text = hoverText();
if (text != null){
int key = 0;
if (keyAction() != null){
int key = KeyBindings.getFirstKeyForAction(keyAction(), ControllerHandler.controllerPointerActive());
if (key != 0){
text += " _(" + KeyBindings.getKeyName(key) + ")_";
}
key = KeyBindings.getFirstKeyForAction(keyAction(), ControllerHandler.controllerActive);
}
if (key == 0 && secondaryTooltipAction() != null){
key = KeyBindings.getFirstKeyForAction(secondaryTooltipAction(), ControllerHandler.controllerActive);
}
if (key != 0){
text += " _(" + KeyBindings.getKeyName(key) + ")_";
}
hoverTip = new Tooltip(Button.this, text, 80);
Button.this.parent.addToFront(hoverTip);
@@ -129,6 +135,11 @@ public class Button extends Component {
public GameAction keyAction(){
return null;
}
//used in cases where the main key action isn't bound, but a secondary action can be used for the tooltip
public GameAction secondaryTooltipAction(){
return null;
}
@Override
public void update() {
@@ -638,6 +638,11 @@ public class InventoryPane extends Component {
}
}
@Override
public GameAction secondaryTooltipAction() {
return SPDAction.INVENTORY_SELECTOR;
}
@Override
protected String hoverText() {
if (bag != null) {
@@ -59,6 +59,11 @@ public class LootIndicator extends Tag {
public GameAction keyAction() {
return SPDAction.TAG_LOOT;
}
@Override
public GameAction secondaryTooltipAction() {
return SPDAction.WAIT_OR_PICKUP;
}
};
slot.showExtraInfo( false );
add( slot );
@@ -119,6 +119,10 @@ public class QuickSlotButton extends Button {
return QuickSlotButton.this.keyAction();
}
@Override
public GameAction secondaryTooltipAction(){
return QuickSlotButton.this.secondaryTooltipAction();
}
@Override
protected boolean onLongClick() {
return QuickSlotButton.this.onLongClick();
}
@@ -190,6 +194,11 @@ public class QuickSlotButton extends Button {
}
}
@Override
public GameAction secondaryTooltipAction() {
return SPDAction.QUICKSLOT_SELECTOR;
}
@Override
protected String hoverText() {
if (slot.item == null){
@@ -135,7 +135,7 @@ public class Toolbar extends Component {
}
String info = "";
if (ControllerHandler.controllerPointerActive()){
if (ControllerHandler.controllerActive){
info += KeyBindings.getKeyName(KeyBindings.getFirstKeyForAction(GameAction.LEFT_CLICK, true)) + ": " + Messages.get(Toolbar.class, "quickslot_select") + "\n";
info += KeyBindings.getKeyName(KeyBindings.getFirstKeyForAction(GameAction.RIGHT_CLICK, true)) + ": " + Messages.get(Toolbar.class, "quickslot_assign") + "\n";
info += KeyBindings.getKeyName(KeyBindings.getFirstKeyForAction(GameAction.BACK, true)) + ": " + Messages.get(Toolbar.class, "quickslot_cancel");
@@ -208,6 +208,11 @@ public class Toolbar extends Component {
return SPDAction.WAIT;
}
@Override
public GameAction secondaryTooltipAction() {
return SPDAction.WAIT_OR_PICKUP;
}
@Override
protected String hoverText() {
return Messages.titleCase(Messages.get(WndKeyBindings.class, "wait"));
@@ -323,6 +328,11 @@ public class Toolbar extends Component {
return SPDAction.INVENTORY;
}
@Override
public GameAction secondaryTooltipAction() {
return SPDAction.INVENTORY_SELECTOR;
}
@Override
protected String hoverText() {
return Messages.titleCase(Messages.get(WndKeyBindings.class, "inventory"));
@@ -371,7 +381,7 @@ public class Toolbar extends Component {
images[i] = new ItemSprite(bags.get(i));
}
String info = "";
if (ControllerHandler.controllerPointerActive()){
if (ControllerHandler.controllerActive){
info += KeyBindings.getKeyName(KeyBindings.getFirstKeyForAction(GameAction.LEFT_CLICK, true)) + ": " + Messages.get(Toolbar.class, "container_select") + "\n";
info += KeyBindings.getKeyName(KeyBindings.getFirstKeyForAction(GameAction.BACK, true)) + ": " + Messages.get(Toolbar.class, "container_cancel");
} else {
@@ -413,7 +423,7 @@ public class Toolbar extends Component {
}
String info = "";
if (ControllerHandler.controllerPointerActive()){
if (ControllerHandler.controllerActive){
info += KeyBindings.getKeyName(KeyBindings.getFirstKeyForAction(GameAction.LEFT_CLICK, true)) + ": " + Messages.get(Toolbar.class, "item_select") + "\n";
info += KeyBindings.getKeyName(KeyBindings.getFirstKeyForAction(GameAction.RIGHT_CLICK, true)) + ": " + Messages.get(Toolbar.class, "item_use") + "\n";
info += KeyBindings.getKeyName(KeyBindings.getFirstKeyForAction(GameAction.BACK, false)) + ": " + Messages.get(Toolbar.class, "item_cancel");
@@ -113,7 +113,7 @@ public class WndSettings extends WndTabbed {
if (DeviceCompat.hasHardKeyboard() || ControllerHandler.isControllerConnected()) {
add( input );
Image icon;
if (ControllerHandler.controllerPointerActive() || !DeviceCompat.hasHardKeyboard()){
if (ControllerHandler.controllerActive || !DeviceCompat.hasHardKeyboard()){
icon = Icons.get(Icons.CONTROLLER);
} else {
icon = Icons.get(Icons.KEYBOARD);