From 0f44a3761cf49afa0d812eefbd02435779200b78 Mon Sep 17 00:00:00 2001 From: neoapps-dev Date: Fri, 7 Aug 2026 22:18:29 +0300 Subject: [PATCH] feat: remove more buttons from android --- src/components/common/CapePreview.tsx | 24 ++ src/components/common/SkinViewer.tsx | 24 ++ src/components/views/SettingsView.tsx | 77 ++++--- src/components/views/SetupView.tsx | 122 +++++----- src/components/views/VersionsView.tsx | 310 ++++++++++++++------------ src/hooks/usePlatform.ts | 6 +- 6 files changed, 321 insertions(+), 242 deletions(-) diff --git a/src/components/common/CapePreview.tsx b/src/components/common/CapePreview.tsx index 9b57f99..a383fbe 100644 --- a/src/components/common/CapePreview.tsx +++ b/src/components/common/CapePreview.tsx @@ -144,13 +144,37 @@ const CapePreview = memo(function CapePreview({ render(); } }; + const onTouchStart = (e: TouchEvent) => { + const t = e.touches[0]; + if (!t) return; + isDragging = true; + previousMousePosition = { x: t.clientX, y: t.clientY }; + }; + const onTouchMove = (e: TouchEvent) => { + const t = e.touches[0]; + if (isDragging && groupRef.current && t) { + e.preventDefault(); + groupRef.current.rotation.y += + (t.clientX - previousMousePosition.x) * 0.01; + previousMousePosition = { x: t.clientX, y: t.clientY }; + render(); + } + }; + const onTouchEnd = () => { + isDragging = false; + }; renderer.domElement.addEventListener("mousedown", onMouseDown); window.addEventListener("mousemove", onMouseMove); window.addEventListener("mouseup", onMouseUp); + renderer.domElement.addEventListener("touchstart", onTouchStart, { passive: true }); + window.addEventListener("touchmove", onTouchMove, { passive: false }); + window.addEventListener("touchend", onTouchEnd); return () => { active = false; window.removeEventListener("mousemove", onMouseMove); window.removeEventListener("mouseup", onMouseUp); + window.removeEventListener("touchmove", onTouchMove); + window.removeEventListener("touchend", onTouchEnd); scene.traverse((object) => { if (object instanceof THREE.Mesh) { if (object.geometry) object.geometry.dispose(); diff --git a/src/components/common/SkinViewer.tsx b/src/components/common/SkinViewer.tsx index a2491c6..864625e 100644 --- a/src/components/common/SkinViewer.tsx +++ b/src/components/common/SkinViewer.tsx @@ -404,15 +404,39 @@ const SkinViewer = memo(function SkinViewer({ requestRenderRef.current?.(); } }; + const onTouchStart = (e: TouchEvent) => { + const t = e.touches[0]; + if (!t) return; + isDragging = true; + previousMousePosition = { x: t.clientX, y: t.clientY }; + }; + const onTouchMove = (e: TouchEvent) => { + const t = e.touches[0]; + if (isDragging && t) { + e.preventDefault(); + const delta = (t.clientX - previousMousePosition.x) * 0.01; + playerGroup.rotation.y += delta; + previousMousePosition = { x: t.clientX, y: t.clientY }; + requestRenderRef.current?.(); + } + }; + const onTouchEnd = () => { + isDragging = false; + }; requestRenderRef.current = () => renderer.render(scene, camera); requestRenderRef.current(); renderer.domElement.addEventListener("mousedown", onMouseDown); window.addEventListener("mousemove", onMouseMove); window.addEventListener("mouseup", onMouseUp); + renderer.domElement.addEventListener("touchstart", onTouchStart, { passive: true }); + window.addEventListener("touchmove", onTouchMove, { passive: false }); + window.addEventListener("touchend", onTouchEnd); return () => { window.removeEventListener("mousemove", onMouseMove); window.removeEventListener("mouseup", onMouseUp); + window.removeEventListener("touchmove", onTouchMove); + window.removeEventListener("touchend", onTouchEnd); scene.traverse((object) => { if (object instanceof THREE.Mesh) { if (object.geometry) object.geometry.dispose(); diff --git a/src/components/views/SettingsView.tsx b/src/components/views/SettingsView.tsx index a220e92..db570ee 100644 --- a/src/components/views/SettingsView.tsx +++ b/src/components/views/SettingsView.tsx @@ -58,7 +58,7 @@ const SettingsView = memo(function SettingsView() { runnerDownloadProgress, downloadRunner, } = useGame(); - const { isLinux, isMac } = usePlatform(); + const { isLinux, isMac, isAndroid } = usePlatform(); const [focusIndex, setFocusIndex] = useState(null); const [currentSubMenu, setCurrentSubMenu] = useState< "main" | "audio" | "video" | "launcher" | "game" | "plugins" @@ -430,12 +430,14 @@ const SettingsView = memo(function SettingsView() { type: "button", onClick: handleFullscreenToggle, }); - items.push({ - id: "rpc", - label: `Discord RPC: ${rpcEnabled ? "ON" : "OFF"}`, - type: "button", - onClick: handleRpcToggle, - }); + if (!isAndroid) { + items.push({ + id: "rpc", + label: `Discord RPC: ${rpcEnabled ? "ON" : "OFF"}`, + type: "button", + onClick: handleRpcToggle, + }); + } items.push({ id: "skip_intro", label: `Skip Intro: ${skipIntro ? "ON" : "OFF"}`, @@ -448,7 +450,7 @@ const SettingsView = memo(function SettingsView() { type: "button", onClick: handleLegacyToggle, }); - if (isLinux) { + if (isLinux && !isAndroid) { items.push({ id: "runner", label: `Runner: ${selectedRunnerName}`, @@ -479,33 +481,37 @@ const SettingsView = memo(function SettingsView() { }); } - items.push({ - id: "export_settings", - label: "Export Settings", - type: "button", - onClick: async () => { - playPressSound(); - try { - await TauriService.exportSettings(); - } catch (e) { - if (e !== "CANCELED") console.error(e); - } - }, - }); - items.push({ - id: "import_settings", - label: "Import Settings", - type: "button", - onClick: async () => { - playPressSound(); - try { - await TauriService.importSettings(); - window.location.reload(); - } catch (e) { - if (e !== "CANCELED") console.error(e); - } - }, - }); + if (!isAndroid) { + items.push({ + id: "export_settings", + label: "Export Settings", + type: "button", + onClick: async () => { + playPressSound(); + try { + await TauriService.exportSettings(); + } catch (e) { + if (e !== "CANCELED") console.error(e); + } + }, + }); + } + if (!isAndroid) { + items.push({ + id: "import_settings", + label: "Import Settings", + type: "button", + onClick: async () => { + playPressSound(); + try { + await TauriService.importSettings(); + window.location.reload(); + } catch (e) { + if (e !== "CANCELED") console.error(e); + } + }, + }); + } items.push({ id: "reset_setup", label: "Reset Setup", @@ -553,6 +559,7 @@ const SettingsView = memo(function SettingsView() { animationsEnabled, layout, isLinux, + isAndroid, mangohudEnabled, selectedRunnerName, isRunnerDownloading, diff --git a/src/components/views/SetupView.tsx b/src/components/views/SetupView.tsx index 255c228..763c4a5 100644 --- a/src/components/views/SetupView.tsx +++ b/src/components/views/SetupView.tsx @@ -7,7 +7,7 @@ interface SetupViewProps { } const SetupView: React.FC = ({ onComplete }) => { - const { isLinux, isMac } = usePlatform(); + const { isLinux, isMac, isAndroid } = usePlatform(); const { username, setUsername, setHasCompletedSetup, @@ -82,7 +82,7 @@ const SetupView: React.FC = ({ onComplete }) => { setCurrentStep(2); setFocusIndex(0); } else if (currentStep === 2) { - setConfigRpc(enableDiscordRPC); + if (!isAndroid) setConfigRpc(enableDiscordRPC); setCurrentStep(3); setFocusIndex(0); } else if (currentStep === 3) { @@ -108,7 +108,7 @@ const SetupView: React.FC = ({ onComplete }) => { if (isLinux) count = runners.length + 2; else if (isMac) count = 3; else count = 2; - } else if (currentStep === 2) count = 4; + } else if (currentStep === 2) count = isAndroid ? 3 : 4; else if (currentStep === 3) count = 2; if (e.key === "ArrowDown" || e.key === "Tab") { e.preventDefault(); @@ -134,10 +134,16 @@ const SetupView: React.FC = ({ onComplete }) => { else if (focusIndex === 1) handleNext(); } } else if (currentStep === 2) { - if (focusIndex === 0) { setEnableDiscordRPC(!enableDiscordRPC); playPressSound(); } - else if (focusIndex === 1) { playPressSound(); } - else if (focusIndex === 2) handleBack(); - else if (focusIndex === 3) handleNext(); + if (isAndroid) { + if (focusIndex === 0) { playPressSound(); } + else if (focusIndex === 1) handleBack(); + else if (focusIndex === 2) handleNext(); + } else { + if (focusIndex === 0) { setEnableDiscordRPC(!enableDiscordRPC); playPressSound(); } + else if (focusIndex === 1) { playPressSound(); } + else if (focusIndex === 2) handleBack(); + else if (focusIndex === 3) handleNext(); + } } else if (currentStep === 3) { if (focusIndex === 0) handleBack(); else if (focusIndex === 1) handleNext(); @@ -146,7 +152,7 @@ const SetupView: React.FC = ({ onComplete }) => { }; window.addEventListener("keydown", handleKey); return () => window.removeEventListener("keydown", handleKey); - }, [currentStep, focusIndex, runners, enableDiscordRPC, isLinux, isMac, tempUsername]); + }, [currentStep, focusIndex, runners, enableDiscordRPC, isLinux, isMac, isAndroid, tempUsername]); const handleMacosSetup = async () => { playPressSound(); @@ -412,44 +418,46 @@ const SetupView: React.FC = ({ onComplete }) => {
- + {enableDiscordRPC && ( + checked + )} +
+ + )} )} - {!isInstalled && ( + {!isAndroid && !isInstalled && ( )}
- - - - + )} + {!isAndroid && ( + - + )} + {!isAndroid && ( + - + )} + {!isAndroid && ( + + + + + + + Backup + + )} + {!isAndroid && ( + + )} + {!isAndroid && ( + + )}