summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 90507ff)
raw | patch | inline | side by side (parent: 90507ff)
author | fredboy <fredboy@protonmail.com> | |
Tue, 23 Apr 2024 03:08:18 +0000 (10:08 +0700) | ||
committer | fredboy <fredboy@protonmail.com> | |
Tue, 23 Apr 2024 03:09:51 +0000 (10:09 +0700) |
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java b/core/src/ru/deadsoftware/cavedroid/game/GameRenderer.java
index 62950114bf1ac90246e108989a06d11e062b67b3..7647e69c2a6c0ad9d782de5b5533ccc75123fec1 100644 (file)
@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());
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/action/keys/MouseInputActionKey.kt b/core/src/ru/deadsoftware/cavedroid/game/input/action/keys/MouseInputActionKey.kt
index ce5bdc2047f62dbc881552e21bcd346ea421c0f9..58227603ae8b08f2b295fbf14f89b0e8adc05ffa 100644 (file)
override val touchUp: Boolean
) : MouseInputActionKey
+ data class Touch(
+ override val touchUp: Boolean
+ ) : MouseInputActionKey
+
data class Scroll(
val amountX: Float,
val amountY: Float
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt
index 2929c4297d793acbeb310fdf5ac31d1f93ee22e5..1f76039c78fe1575c5fcf6c878e1f69d68cfb30d 100644 (file)
--- a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt
+++ b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/CloseGameWindowMouseInputHandler.kt
override fun checkConditions(action: MouseInputAction): Boolean {
return gameWindowsManager.getCurrentWindow() != GameUiWindow.NONE &&
- action.actionKey is MouseInputActionKey.Left &&
+ (action.actionKey is MouseInputActionKey.Left || action.actionKey is MouseInputActionKey.Touch) &&
!action.actionKey.touchUp &&
!isInsideWindow(action, getCurrentWindowTexture())
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/HotbarMouseInputHandler.kt b/core/src/ru/deadsoftware/cavedroid/game/input/handler/mouse/HotbarMouseInputHandler.kt
index 3c2a16317ce6628946aecab8a152916c778e3257..5f983c5967feb860175e45c78effe82b919f46c4 100644 (file)
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
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/input/mapper/MouseInputActionMapper.kt b/core/src/ru/deadsoftware/cavedroid/game/input/mapper/MouseInputActionMapper.kt
index 666154e81c813f14ecff7f42531c31e5847e14bf..254cee2f49f2cda6ccdc5d48ee34264ed00556e0 100644 (file)
Input.Buttons.LEFT -> MouseInputActionKey.Left(touchUp)
Input.Buttons.RIGHT -> MouseInputActionKey.Right(touchUp)
Input.Buttons.MIDDLE -> MouseInputActionKey.Middle(touchUp)
+ -1 -> MouseInputActionKey.Touch(touchUp)
else -> null
}
}