@GameScope
public class GameRenderer extends Renderer {
+ private static final TouchButton nullButton = new TouchButton(null, -1, true);
+
private final MainConfig mMainConfig;
private final MobsController mMobsController;
private final List<IGameRenderer> mRenderers;
float touchY = transformScreenY(screenY);
if (mMainConfig.isTouch()) {
- @CheckForNull TouchButton touchedKey = getTouchedKey(touchX, touchY);
- if (touchedKey != null && touchedKey.isMouse()) {
+ TouchButton touchedKey = getTouchedKey(touchX, touchY);
+ if (touchedKey.isMouse()) {
return onMouseActionEvent(screenX, screenY, touchedKey.getCode(), true);
- } else if (touchedKey != null) {
+ } else {
return keyUp(touchedKey.getCode());
}
}
return onMouseActionEvent(screenX, screenY, button, true);
}
- @CheckForNull
private TouchButton getTouchedKey(float touchX, float touchY) {
for (ObjectMap.Entry<String, TouchButton> entry : Assets.guiMap) {
TouchButton button = entry.value;
return button;
}
}
- return null;
+ return nullButton;
}
@Override
mTouchDownY = touchY;
if (mMainConfig.isTouch()) {
- @CheckForNull TouchButton touchedKey = getTouchedKey(touchX, touchY);
- if (touchedKey != null && touchedKey.isMouse()) {
+ TouchButton touchedKey = getTouchedKey(touchX, touchY);
+ if (touchedKey.isMouse()) {
return onMouseActionEvent(screenX, screenY, touchedKey.getCode(), false);
- } else if (touchedKey != null) {
+ } else {
return keyDown(touchedKey.getCode());
}
}
override fun checkConditions(action: MouseInputAction): Boolean {
return buttonHoldTask?.isScheduled == true ||
- (action.actionKey is MouseInputActionKey.Left && isInsideHotbar(action) || action.actionKey is MouseInputActionKey.Scroll) &&
+ ((action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Touch)
+ && isInsideHotbar(action)
+ || action.actionKey is MouseInputActionKey.Scroll) &&
gameWindowsManager.getCurrentWindow() == GameUiWindow.NONE
}