android: frontend: InputOverlay: Fix setting save for portrait mode.
This commit is contained in:
parent
234e1f2ad2
commit
6f5928f1bf
@ -467,6 +467,10 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener {
|
|||||||
int fingerPositionX = (int) event.getX(pointerIndex);
|
int fingerPositionX = (int) event.getX(pointerIndex);
|
||||||
int fingerPositionY = (int) event.getY(pointerIndex);
|
int fingerPositionY = (int) event.getY(pointerIndex);
|
||||||
|
|
||||||
|
String orientation =
|
||||||
|
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ?
|
||||||
|
"-Portrait" : "";
|
||||||
|
|
||||||
// Maybe combine Button and Joystick as subclasses of the same parent?
|
// Maybe combine Button and Joystick as subclasses of the same parent?
|
||||||
// Or maybe create an interface like IMoveableHUDControl?
|
// Or maybe create an interface like IMoveableHUDControl?
|
||||||
|
|
||||||
@ -496,7 +500,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener {
|
|||||||
// Persist button position by saving new place.
|
// Persist button position by saving new place.
|
||||||
saveControlPosition(mButtonBeingConfigured.getId(),
|
saveControlPosition(mButtonBeingConfigured.getId(),
|
||||||
mButtonBeingConfigured.getBounds().left,
|
mButtonBeingConfigured.getBounds().left,
|
||||||
mButtonBeingConfigured.getBounds().top);
|
mButtonBeingConfigured.getBounds().top, orientation);
|
||||||
mButtonBeingConfigured = null;
|
mButtonBeingConfigured = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -528,7 +532,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener {
|
|||||||
if (mDpadBeingConfigured == dpad) {
|
if (mDpadBeingConfigured == dpad) {
|
||||||
// Persist button position by saving new place.
|
// Persist button position by saving new place.
|
||||||
saveControlPosition(mDpadBeingConfigured.getId(0),
|
saveControlPosition(mDpadBeingConfigured.getId(0),
|
||||||
mDpadBeingConfigured.getBounds().left, mDpadBeingConfigured.getBounds().top);
|
mDpadBeingConfigured.getBounds().left, mDpadBeingConfigured.getBounds().top,
|
||||||
|
orientation);
|
||||||
mDpadBeingConfigured = null;
|
mDpadBeingConfigured = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -556,7 +561,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener {
|
|||||||
if (mJoystickBeingConfigured != null) {
|
if (mJoystickBeingConfigured != null) {
|
||||||
saveControlPosition(mJoystickBeingConfigured.getId(),
|
saveControlPosition(mJoystickBeingConfigured.getId(),
|
||||||
mJoystickBeingConfigured.getBounds().left,
|
mJoystickBeingConfigured.getBounds().left,
|
||||||
mJoystickBeingConfigured.getBounds().top);
|
mJoystickBeingConfigured.getBounds().top, orientation);
|
||||||
mJoystickBeingConfigured = null;
|
mJoystickBeingConfigured = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -670,11 +675,11 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener {
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveControlPosition(int sharedPrefsId, int x, int y) {
|
private void saveControlPosition(int sharedPrefsId, int x, int y, String orientation) {
|
||||||
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
SharedPreferences.Editor sPrefsEditor = sPrefs.edit();
|
SharedPreferences.Editor sPrefsEditor = sPrefs.edit();
|
||||||
sPrefsEditor.putFloat(sharedPrefsId + "-X", x);
|
sPrefsEditor.putFloat(sharedPrefsId + orientation + "-X", x);
|
||||||
sPrefsEditor.putFloat(sharedPrefsId + "-Y", y);
|
sPrefsEditor.putFloat(sharedPrefsId + orientation + "-Y", y);
|
||||||
sPrefsEditor.apply();
|
sPrefsEditor.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user