Adaptation to be able to play on android

This commit is contained in:
2026-05-12 14:59:04 +02:00
parent f1111d06c2
commit 7d9328b865
15 changed files with 122 additions and 73 deletions

View File

@@ -1125,6 +1125,9 @@ bool Minecraft::useTouchscreen() {
#elif defined(RPI)
return false;
#endif
if (options.getBooleanValue(OPTIONS_TOUCH_OVERRIDE)) {
return options.getBooleanValue(OPTIONS_USE_TOUCHSCREEN);
}
return options.getBooleanValue(OPTIONS_USE_TOUCHSCREEN) && !_supportsNonTouchscreen;
}
bool Minecraft::supportNonTouchScreen() {
@@ -1217,13 +1220,14 @@ void Minecraft::setSize(int w, int h) {
// determine gui scale, optionally overriding auto
if (guiScale != 0) {
// manual selection: 1->small, 2->medium, 3->large, 4->larger, 5->largest
// manual selection: 1->tiny, 2->small, 3->medium, 4->large, 5->larger, 6->largest
switch (guiScale) {
case 1: Gui::GuiScale = 2.0f; break;
case 2: Gui::GuiScale = 3.0f; break;
case 3: Gui::GuiScale = 4.0f; break;
case 4: Gui::GuiScale = 5.0f; break;
case 5: Gui::GuiScale = 6.0f; break;
case 1: Gui::GuiScale = 1.0f; break;
case 2: Gui::GuiScale = 2.0f; break;
case 3: Gui::GuiScale = 3.0f; break;
case 4: Gui::GuiScale = 4.0f; break;
case 5: Gui::GuiScale = 5.0f; break;
case 6: Gui::GuiScale = 6.0f; break;
default: Gui::GuiScale = 1.0f; break; // auto
}
} else {
@@ -1283,16 +1287,15 @@ void Minecraft::setSize(int w, int h) {
void Minecraft::reloadOptions() {
options.save();
bool wasTouchscreen = options.getBooleanValue(OPTIONS_USE_TOUCHSCREEN);
options.set(OPTIONS_USE_TOUCHSCREEN, useTouchscreen());
options.save();
if ((wasTouchscreen != useTouchscreen()) || (inputHolder == 0))
_reloadInput();
bool useTouch = useTouchscreen();
_reloadInput();
gui.refreshTouchState();
// user->name = options.username;
LOGI("Reloading-options\n");
LOGI("Reloading-options (touch=%d)\n", useTouch);
// @todo @fix Android and iOS behaves a bit differently when leaving
// an options screen (Android recreates OpenGL surface)