From 7a183a192a20a975968b5a87af5f79bbbbb30998 Mon Sep 17 00:00:00 2001 From: Helixod Date: Tue, 2 Jun 2026 16:24:38 +0000 Subject: [PATCH] . --- src/KubikonPlayer/KubikonPlayer.jsx | 111 +++++++++++++++++++++++----- 1 file changed, 91 insertions(+), 20 deletions(-) diff --git a/src/KubikonPlayer/KubikonPlayer.jsx b/src/KubikonPlayer/KubikonPlayer.jsx index 9d62987..b5fb6c2 100644 --- a/src/KubikonPlayer/KubikonPlayer.jsx +++ b/src/KubikonPlayer/KubikonPlayer.jsx @@ -22,7 +22,7 @@ import { useAuth } from '../auth/PlayerAuth'; import RublocsLogo from '../components/RublocsLogo/RublocsLogo'; import useDeviceType from '../hooks/useDeviceType'; import KubikonMobileControls from './KubikonMobileControls'; - +// загрузка плейсов начинается на строке 1163 // Плеер живёт на player.rublox.pro — он не знает SPA-роутов Майнкрафтии // (/kubikon, /login, /auth). Поэтому вместо navigate(...) делаем // явный window.location.assign на внешний домен. @@ -252,6 +252,9 @@ const KubikonPlayer = () => { // Появляется после submitLeaderboard если бэк выдал rating_award текущему юзеру. // null | { place: 1|2|3, amount: number } const [ratingToast, setRatingToast] = useState(null); + const [placeName, setPlaceName] = useState('Загрузка игры…'); + const [placeImage, setPlaceImage] = useState(null); + const [studioName, setStudioName] = useState(null); const timerRafRef = useRef(null); /** Кэш загруженного project_data для soft-restart игры. */ const initialStateRef = useRef(null); @@ -684,6 +687,47 @@ const KubikonPlayer = () => { return () => { alive = false; clearInterval(t); }; }, [projectId, userId, sessionId, loading]); + // Загрузка названия и картинки плейса с сервера + // Загрузка названия, картинки и автора плейса с сервера + // Загрузка названия, картинки и автора плейса + useEffect(() => { + if (!projectId) return; + if (!userId) { + console.log('[Loading] Ждём userId...'); + return; // Ждём пока userId загрузится + } + + async function loadPlaceData() { + try { + // Пытаемся загрузить данные через API + const response = await Kubikon3DApi.getProjectForPlay(projectId, userId); + const title = response?.data?.title; + const thumbnail = response?.data?.thumbnail; + const author = response?.data?.author_username; + + if (title) { + setPlaceName(title); + } else { + setPlaceName(`Плейс ${projectId}`); + } + + if (thumbnail) { + setPlaceImage(thumbnail); + } + + if (author) { + setStudioName(author); + } + + } catch (error) { + console.warn('[KubikonPlayer] Не удалось загрузить данные плейса:', error); + setPlaceName(`Плейс ${projectId}`); + } + } + + loadPlaceData(); + }, [projectId, userId]); // Убрал meta из зависимостей! + // Хоткеи 1-5 для слотов инвентаря. // Babylon ловит ввод на canvas — слушаем в capture-phase на window // и не привязываемся к isPlaying (state-флаг может быть ещё false на старте). @@ -1132,13 +1176,14 @@ const KubikonPlayer = () => { }} /> {/* Loading-оверлей */} + {/*не меняйте пожалуйста загрузку, работаю над ней*/} {loading && (
{ borderRadius: 20, animation: 'hudPulseRing 1.6s ease-out infinite', }} /> - + {placeImage ? ( + {placeName} + ) : ( + + )}
+ {/* Полупрозрачный тёмно-серый пузырь для текста */}
- Загрузка игры… -
-
- Рублокс • 3D -
+ display: 'flex', alignItems: 'center', gap: 10, + fontSize: 15, fontWeight: 700, letterSpacing: 0.3, + }}> +
+ {placeName || 'Загрузка игры…'} +
+ +
+ {studioName || 'Имя автора'} +
+
)} + {/* Игровой UI (HUD, GUI, hotbar, прицел в первом лице) */} {/* Игровой UI (HUD, GUI, hotbar, прицел в первом лице) */} {!loading && ( @@ -2426,3 +2496,4 @@ const voteBtnStyle = (active, kind) => { }; export default KubikonPlayer; +