MikaFil commited on
Commit
7a6465d
Β·
verified Β·
1 Parent(s): 4678af2

Update interface.js

Browse files
Files changed (1) hide show
  1. interface.js +98 -2
interface.js CHANGED
@@ -13,6 +13,7 @@
13
  if (!playcanvasUrl) return;
14
 
15
  const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
 
16
  const id = Math.random().toString(36).substr(2, 8);
17
 
18
  // ─── 4. Calcul des ratios (Desktop & Mobile Portrait) ────────────────────────
@@ -73,10 +74,12 @@
73
  border: none;
74
  display: block;
75
  }
76
- .pc-fs-btn-${id} {
 
 
 
77
  position: absolute;
78
  top: 10px;
79
- right: 10px;
80
  z-index: 10;
81
  width: 36px;
82
  height: 36px;
@@ -90,6 +93,46 @@
90
  cursor: pointer;
91
  user-select: none;
92
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  `;
94
  document.head.appendChild(style);
95
 
@@ -112,9 +155,45 @@
112
  fsBtn.className = `pc-fs-btn-${id}`;
113
  fsBtn.textContent = '⇱';
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  inner.appendChild(iframe);
116
  wrapper.appendChild(inner);
 
117
  wrapper.appendChild(fsBtn);
 
118
  scriptTag.parentNode.insertBefore(wrapper, scriptTag.nextSibling);
119
 
120
  // ─── 7. Γ‰tat & Helper ────────────────────────────────────────────────────────
@@ -126,6 +205,22 @@
126
  return (CSS && CSS.supports && CSS.supports('height', '100dvh')) ? '100dvh' : '100vh';
127
  }
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  // ─── 8. Styles Plein Γ‰cran ───────────────────────────────────────────────────
130
  function applyFullscreenStyles() {
131
  const h = isIOS ? getHeightUnit() : '100vh';
@@ -166,6 +261,7 @@
166
 
167
  // ─── 9. Gestionnaires d'Γ©vΓ©nements ───────────────────────────────────────────
168
  function enterFullscreen() {
 
169
  if (isIOS) {
170
  applyFakeFullscreenStyles();
171
  document.body.style.overflow = 'hidden';
 
13
  if (!playcanvasUrl) return;
14
 
15
  const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
16
+ const isMobile = isIOS || /Android/i.test(navigator.userAgent);
17
  const id = Math.random().toString(36).substr(2, 8);
18
 
19
  // ─── 4. Calcul des ratios (Desktop & Mobile Portrait) ────────────────────────
 
74
  border: none;
75
  display: block;
76
  }
77
+
78
+ /* ── Boutons (fullscreen + help) ── */
79
+ .pc-fs-btn-${id},
80
+ .pc-help-btn-${id} {
81
  position: absolute;
82
  top: 10px;
 
83
  z-index: 10;
84
  width: 36px;
85
  height: 36px;
 
93
  cursor: pointer;
94
  user-select: none;
95
  }
96
+ .pc-fs-btn-${id} {
97
+ right: 10px;
98
+ }
99
+ .pc-help-btn-${id} {
100
+ right: 54px; /* 10px + 36px + 8px de marge */
101
+ }
102
+
103
+ /* ── Panneau d'aide ── */
104
+ .pc-help-panel-${id} {
105
+ display: none;
106
+ position: absolute;
107
+ top: 54px;
108
+ right: 10px;
109
+ z-index: 20;
110
+ background: #2E2E2EB3;
111
+ color: #fff;
112
+ border-radius: 8px;
113
+ padding: 10px 14px 10px 14px;
114
+ font-size: 13px;
115
+ line-height: 1.7;
116
+ min-width: 220px;
117
+ max-width: 80%;
118
+ box-sizing: border-box;
119
+ }
120
+ .pc-help-panel-${id}.visible {
121
+ display: block;
122
+ }
123
+ .pc-help-close-${id} {
124
+ position: absolute;
125
+ top: 4px;
126
+ right: 10px;
127
+ cursor: pointer;
128
+ font-size: 18px;
129
+ line-height: 1;
130
+ color: #fff;
131
+ user-select: none;
132
+ }
133
+ .pc-help-text-${id} {
134
+ margin-top: 4px;
135
+ }
136
  `;
137
  document.head.appendChild(style);
138
 
 
155
  fsBtn.className = `pc-fs-btn-${id}`;
156
  fsBtn.textContent = '⇱';
157
 
158
+ const helpBtn = document.createElement('button');
159
+ helpBtn.className = `pc-help-btn-${id}`;
160
+ helpBtn.textContent = '?';
161
+
162
+ // Panneau d'aide
163
+ const helpPanel = document.createElement('div');
164
+ helpPanel.className = `pc-help-panel-${id}`;
165
+
166
+ const helpClose = document.createElement('span');
167
+ helpClose.className = `pc-help-close-${id}`;
168
+ helpClose.textContent = 'Γ—';
169
+
170
+ const helpText = document.createElement('div');
171
+ helpText.className = `pc-help-text-${id}`;
172
+
173
+ if (isMobile) {
174
+ helpText.innerHTML =
175
+ '- Se déplacer avec les flèches.<br>' +
176
+ '- Tourner avec un doigt.<br>' +
177
+ '- Zoomer avec deux doigts.<br>' +
178
+ '- ⇱ plein Γ©cran.<br>' +
179
+ '- Modifier la qualitΓ© avec le menu Γ  gauche.';
180
+ } else {
181
+ helpText.innerHTML =
182
+ '- Se déplacer avec les flèches ou Z, Q, S, D.<br>' +
183
+ '- Tourner avec clic droit.<br>' +
184
+ '- Zoomer avec la molette.<br>' +
185
+ '- ⇱ plein Γ©cran.<br>' +
186
+ '- Modifier la qualitΓ© avec le menu Γ  gauche.';
187
+ }
188
+
189
+ helpPanel.appendChild(helpClose);
190
+ helpPanel.appendChild(helpText);
191
+
192
  inner.appendChild(iframe);
193
  wrapper.appendChild(inner);
194
+ wrapper.appendChild(helpBtn);
195
  wrapper.appendChild(fsBtn);
196
+ wrapper.appendChild(helpPanel);
197
  scriptTag.parentNode.insertBefore(wrapper, scriptTag.nextSibling);
198
 
199
  // ─── 7. Γ‰tat & Helper ────────────────────────────────────────────────────────
 
205
  return (CSS && CSS.supports && CSS.supports('height', '100dvh')) ? '100dvh' : '100vh';
206
  }
207
 
208
+ // ─── Gestion du panneau d'aide ───────────────────────────────────────────────
209
+ function toggleHelpPanel(e) {
210
+ e.stopPropagation();
211
+ helpPanel.classList.toggle('visible');
212
+ }
213
+
214
+ function hideHelpPanel() {
215
+ helpPanel.classList.remove('visible');
216
+ }
217
+
218
+ helpBtn.addEventListener('click', toggleHelpPanel);
219
+ helpClose.addEventListener('click', (e) => {
220
+ e.stopPropagation();
221
+ hideHelpPanel();
222
+ });
223
+
224
  // ─── 8. Styles Plein Γ‰cran ───────────────────────────────────────────────────
225
  function applyFullscreenStyles() {
226
  const h = isIOS ? getHeightUnit() : '100vh';
 
261
 
262
  // ─── 9. Gestionnaires d'Γ©vΓ©nements ───────────────────────────────────────────
263
  function enterFullscreen() {
264
+ hideHelpPanel();
265
  if (isIOS) {
266
  applyFakeFullscreenStyles();
267
  document.body.style.overflow = 'hidden';