@hytopia.com/examples 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,6 +82,9 @@
82
82
  accessory: 5
83
83
  };
84
84
 
85
+ const mouseFollower = createMouseFollower();
86
+ let heldItem = null;
87
+
85
88
  // Setup hytopia data handlers
86
89
  hytopia.onData(data => {
87
90
  if (data.type === 'toggleBackpack') {
@@ -134,15 +137,8 @@
134
137
  }
135
138
  }
136
139
 
137
- function setupEventListeners() {
138
- const closeButton = document.querySelector('.backpack-close');
139
- closeButton.addEventListener('click', closeBackpack);
140
-
141
- let heldItem = null;
142
- const mouseFollower = createMouseFollower();
143
-
144
- // Helper function to get slot info
145
- function getSlotInfo(slot) {
140
+ // Helper function to get slot info
141
+ function getSlotInfo(slot) {
146
142
  if (slot.dataset.slotIndex) {
147
143
  return { type: 'backpack', index: slot.dataset.slotIndex };
148
144
  } else if (slot.dataset.slot) {
@@ -216,8 +212,14 @@
216
212
  // Copy content to mouse follower
217
213
  mouseFollower.innerHTML = contentHTML;
218
214
 
219
- // Copy tooltip if it exists
215
+ // Copy tooltip if it exists and store reference for later restoration
220
216
  if (tooltip) {
217
+ // Store tooltip data for restoration
218
+ heldItem.tooltipData = {
219
+ element: tooltip.cloneNode(true),
220
+ parentSlot: slot
221
+ };
222
+
221
223
  const tooltipClone = tooltip.cloneNode(true);
222
224
  tooltipClone.style.opacity = '1';
223
225
  tooltipClone.style.visibility = 'visible';
@@ -225,15 +227,26 @@
225
227
  tooltipClone.style.position = 'absolute';
226
228
  tooltipClone.style.bottom = 'auto';
227
229
  tooltipClone.style.top = '-8px';
230
+
231
+ // Remove mobile tooltip classes that might interfere
232
+ tooltipClone.classList.remove('mobile-tooltip-visible');
233
+
228
234
  mouseFollower.appendChild(tooltipClone);
235
+
236
+ // Completely remove original tooltip to prevent ghosting
237
+ tooltip.remove();
229
238
  }
239
+
240
+ // Position mouse follower at center of slot
241
+ const slotRect = slot.getBoundingClientRect();
242
+ const centerX = slotRect.left + slotRect.width / 2;
243
+ const centerY = slotRect.top + slotRect.height / 2;
230
244
 
231
- mouseFollower.style.left = mouseX + 'px';
232
- mouseFollower.style.top = mouseY + 'px';
245
+ mouseFollower.style.left = centerX + 15 + 'px';
246
+ mouseFollower.style.top = centerY - 15 + 'px';
233
247
  mouseFollower.classList.add('active');
234
248
  slot.classList.add('backpack-slot-empty');
235
249
 
236
- console.log(`Picked up from ${slotInfo.type}: ${slotInfo.index}`);
237
250
  return true;
238
251
  }
239
252
 
@@ -252,8 +265,15 @@
252
265
  // Reset held item state
253
266
  function resetHeldItem() {
254
267
  if (!heldItem) return;
255
-
268
+
256
269
  heldItem.sourceSlot.classList.remove('backpack-slot-empty');
270
+
271
+ // Restore original tooltip by recreating it
272
+ if (heldItem.tooltipData) {
273
+ const restoredTooltip = heldItem.tooltipData.element.cloneNode(true);
274
+ heldItem.tooltipData.parentSlot.appendChild(restoredTooltip);
275
+ }
276
+
257
277
  mouseFollower.classList.remove('active');
258
278
  mouseFollower.innerHTML = '';
259
279
  heldItem = null;
@@ -263,10 +283,13 @@
263
283
  function cancelHeldItem() {
264
284
  if (!heldItem) return;
265
285
 
266
- console.log(`Cancelled pickup from ${heldItem.sourceType}: ${heldItem.sourceIndex}`);
267
286
  resetHeldItem();
268
287
  }
269
288
 
289
+ function setupEventListeners() {
290
+ const closeButton = document.querySelector('.backpack-close');
291
+ closeButton.addEventListener('click', closeBackpack);
292
+
270
293
  // Setup slot click handlers
271
294
  document.querySelectorAll('.backpack-slot, .backpack-wearable-slot, .backpack-hotbar-slot')
272
295
  .forEach(slot => {
@@ -321,6 +344,16 @@
321
344
  function closeBackpack() {
322
345
  document.querySelector('.backpack-overlay').style.display = 'none';
323
346
  hytopia.lockPointer(true);
347
+
348
+ // Close any open mobile tooltips
349
+ if (window.ItemTooltips) {
350
+ window.ItemTooltips.closeAllMobileTooltips();
351
+ }
352
+
353
+ // Cancel any picked up item
354
+ if (heldItem) {
355
+ cancelHeldItem();
356
+ }
324
357
  }
325
358
 
326
359
  function openBackpack() {
@@ -785,66 +818,80 @@
785
818
 
786
819
  /* Mobile Styles */
787
820
  body.mobile {
788
- --backpack-slot-size: 40px;
789
- --backpack-hotbar-size: 40px;
790
- --backpack-icon-size: 20px;
791
- --backpack-gap: 3px;
792
- --backpack-padding: 6px;
821
+ --backpack-slot-size: 44px;
822
+ --backpack-hotbar-size: 44px;
823
+ --backpack-icon-size: 32px;
824
+ --backpack-gap: 4px;
825
+ --backpack-padding: 8px;
793
826
  }
794
827
 
795
828
  body.mobile .backpack-overlay {
796
- gap: 8px;
797
- padding: 4px;
829
+ gap: 12px;
830
+ padding: 8px;
798
831
  }
799
832
 
800
833
  body.mobile .backpack-container,
801
834
  body.mobile .backpack-hotbar-container {
802
835
  width: auto;
803
- max-width: 500px;
804
- min-width: 320px;
836
+ max-width: 520px;
837
+ min-width: 340px;
838
+ border-radius: 8px;
805
839
  }
806
840
 
807
841
  body.mobile .backpack-header,
808
842
  body.mobile .backpack-hotbar-header {
809
- padding: 4px 8px;
843
+ padding: 8px 12px;
844
+ border-radius: 8px 8px 0 0;
810
845
  }
811
846
 
812
847
  body.mobile .backpack-title,
813
848
  body.mobile .backpack-hotbar-title {
814
- font-size: 12px;
849
+ font-size: 14px;
815
850
  }
816
851
 
817
852
  body.mobile .backpack-close {
818
- width: 20px;
819
- height: 20px;
820
- font-size: 14px;
853
+ width: 24px;
854
+ height: 24px;
855
+ font-size: 16px;
856
+ border-radius: 6px;
821
857
  }
822
858
 
823
859
  body.mobile .backpack-content {
824
- padding: 6px;
825
- gap: 6px;
860
+ padding: 12px;
861
+ gap: 12px;
826
862
  }
827
863
 
828
864
  body.mobile .backpack-wearables-panel {
829
- flex-direction: row;
865
+ flex-direction: column;
830
866
  min-width: auto;
867
+ gap: 12px;
831
868
  }
832
869
 
833
870
  body.mobile .backpack-wearables-slots {
834
871
  justify-items: center;
872
+ padding: 8px;
873
+ border-radius: 6px;
835
874
  }
836
875
 
837
- body.mobile .backpack-wearable-slot,
838
- body.mobile .backpack-slot,
839
- body.mobile .backpack-hotbar-slot {
840
- box-sizing: border-box;
876
+ body.mobile .backpack-grid {
877
+ padding: 8px;
878
+ border-radius: 6px;
841
879
  }
842
880
 
843
- body.mobile .backpack-grid,
844
881
  body.mobile .backpack-hotbar-grid {
845
882
  justify-items: center;
846
883
  width: fit-content;
847
884
  margin: 0 auto;
885
+ padding: 12px;
886
+ border-radius: 0 0 6px 6px;
887
+ }
888
+
889
+ body.mobile .backpack-wearable-slot,
890
+ body.mobile .backpack-slot,
891
+ body.mobile .backpack-hotbar-slot {
892
+ box-sizing: border-box;
893
+ border-radius: 6px;
894
+ border-width: 2px;
848
895
  }
849
896
 
850
897
  body.mobile .backpack-slot-content,
@@ -853,36 +900,58 @@
853
900
  }
854
901
 
855
902
  body.mobile .backpack-item-icon {
856
- width: 32px;
857
- height: 32px;
903
+ width: 36px;
904
+ height: 36px;
858
905
  }
859
906
 
860
907
  body.mobile .backpack-hotbar-slot-icon {
861
- width: 32px;
862
- height: 32px;
908
+ width: 36px;
909
+ height: 36px;
863
910
  }
864
911
 
865
912
  body.mobile .backpack-slot-quantity {
866
- font-size: 7px;
867
- padding: 1px 2px;
868
- bottom: 1px;
869
- right: 1px;
870
- min-width: 8px;
913
+ font-size: 8px;
914
+ padding: 1px 3px;
915
+ bottom: 2px;
916
+ right: 2px;
917
+ min-width: 10px;
918
+ border-radius: 3px;
871
919
  }
872
920
 
873
921
  body.mobile .backpack-hotbar-slot-quantity {
874
922
  font-size: 8px;
875
923
  padding: 1px 3px;
876
- bottom: 1px;
877
- right: 1px;
924
+ bottom: 2px;
925
+ right: 2px;
926
+ min-width: 12px;
927
+ border-radius: 3px;
878
928
  }
879
929
 
880
- body.mobile .backpack-item-tooltip {
881
- display: none;
882
- }
930
+
883
931
 
884
932
  body.mobile .backpack-wearable-slot-label {
885
- font-size: 9px;
933
+ font-size: 7px;
934
+ font-weight: 500;
935
+ }
936
+
937
+ body.mobile .backpack-mouse-follower {
938
+ width: 44px;
939
+ height: 44px;
940
+ border-radius: 6px;
941
+ }
942
+
943
+ body.mobile .backpack-mouse-follower img {
944
+ width: 36px;
945
+ height: 36px;
946
+ }
947
+
948
+ body.mobile .backpack-mouse-follower .backpack-hotbar-slot-quantity {
949
+ font-size: 8px;
950
+ padding: 1px 3px;
951
+ bottom: 2px;
952
+ right: 2px;
953
+ min-width: 10px;
954
+ border-radius: 3px;
886
955
  }
887
956
 
888
957
  .backpack-mouse-follower {
@@ -831,37 +831,40 @@
831
831
 
832
832
 
833
833
  /* Mobile responsive */
834
- @media (max-width: 768px) {
834
+
835
835
  body.mobile {
836
- --crafting-slot-size: 40px;
837
- --crafting-icon-size: 20px;
838
- --crafting-gap: 3px;
839
- --crafting-padding: 6px;
836
+ --crafting-slot-size: 44px;
837
+ --crafting-icon-size: 32px;
838
+ --crafting-gap: 4px;
839
+ --crafting-padding: 8px;
840
840
  }
841
841
 
842
842
  body.mobile .crafting-container {
843
843
  width: auto;
844
- max-width: 500px;
845
- min-width: 320px;
844
+ max-width: 520px;
845
+ min-width: 340px;
846
+ border-radius: 8px;
846
847
  }
847
848
 
848
849
  body.mobile .crafting-content {
849
- padding: 6px;
850
- flex-direction: column;
851
- gap: 8px;
850
+ padding: 12px;
851
+ gap: 12px;
852
852
  }
853
853
 
854
854
  body.mobile .crafting-grid {
855
855
  justify-items: center;
856
856
  width: fit-content;
857
857
  margin: 0 auto;
858
+ padding: 8px;
859
+ border-radius: 6px;
858
860
  }
859
861
 
860
862
  body.mobile .crafting-right-panel {
861
863
  width: auto;
862
864
  flex: 1;
863
- min-height: 80px;
865
+ min-height: 120px;
864
866
  padding: var(--crafting-padding);
867
+ border-radius: 6px;
865
868
  }
866
869
 
867
870
  body.mobile .crafting-panel-content {
@@ -874,10 +877,9 @@
874
877
  padding: 16px;
875
878
  }
876
879
 
877
-
878
-
879
880
  body.mobile .crafting-header {
880
- padding: 4px 8px;
881
+ padding: 8px 12px;
882
+ border-radius: 8px 8px 0 0;
881
883
  }
882
884
 
883
885
  body.mobile .crafting-info {
@@ -890,15 +892,21 @@
890
892
  }
891
893
 
892
894
  body.mobile .crafting-name {
893
- font-size: 12px;
895
+ font-size: 14px;
894
896
  }
895
897
 
896
898
  body.mobile .crafting-title {
897
- font-size: 10px;
899
+ font-size: 12px;
900
+ }
901
+
902
+ body.mobile .crafting-close {
903
+ width: 24px;
904
+ height: 24px;
905
+ font-size: 16px;
898
906
  }
899
907
 
900
908
  body.mobile .crafting-item-details {
901
- gap: 6px;
909
+ gap: 8px;
902
910
  }
903
911
 
904
912
  body.mobile .crafting-item-header {
@@ -908,69 +916,83 @@
908
916
  }
909
917
 
910
918
  body.mobile .crafting-item-header .crafting-item-icon {
911
- width: 24px;
912
- height: 24px;
919
+ width: 28px;
920
+ height: 28px;
913
921
  }
914
922
 
915
923
  body.mobile .crafting-item-name {
916
- font-size: 10px;
924
+ font-size: 11px;
917
925
  }
918
926
 
919
927
  body.mobile .crafting-requirements-title {
920
- font-size: 10px;
928
+ font-size: 11px;
921
929
  }
922
930
 
923
931
  body.mobile .crafting-requirements-list {
924
932
  grid-template-columns: repeat(2, 1fr);
925
- gap: 3px;
933
+ gap: 4px;
926
934
  }
927
935
 
928
936
  body.mobile .crafting-requirement-item {
929
- padding: 3px 4px;
930
- min-height: 28px;
931
- gap: 4px;
937
+ padding: 4px 6px;
938
+ min-height: 32px;
939
+ gap: 6px;
940
+ border-radius: 6px;
932
941
  }
933
942
 
934
943
  body.mobile .crafting-requirement-icon {
935
- width: 16px;
936
- height: 16px;
944
+ width: 18px;
945
+ height: 18px;
937
946
  }
938
947
 
939
948
  body.mobile .crafting-requirement-name {
940
- font-size: 9px;
949
+ font-size: 10px;
941
950
  }
942
951
 
943
952
  body.mobile .crafting-requirement-quantity {
944
- font-size: 8px;
945
- padding: 1px 2px;
953
+ font-size: 9px;
954
+ padding: 1px 3px;
946
955
  }
947
956
 
948
957
  body.mobile .crafting-no-requirements {
949
- font-size: 10px;
950
- padding: 12px;
958
+ font-size: 11px;
959
+ padding: 14px;
951
960
  }
952
961
 
953
962
  body.mobile .crafting-item-actions {
954
- padding-top: 6px;
963
+ padding-top: 8px;
955
964
  }
956
965
 
957
966
  body.mobile .crafting-action-btn {
958
- padding: 6px 12px;
959
- font-size: 10px;
967
+ padding: 8px 14px;
968
+ font-size: 11px;
960
969
  }
961
970
 
962
- body.mobile .crafting-item-stats {
971
+ body.mobile .crafting-slot-quantity {
963
972
  font-size: 8px;
964
- margin-top: 3px;
973
+ padding: 1px 3px;
974
+ bottom: 2px;
975
+ right: 2px;
976
+ min-width: 10px;
977
+ border-radius: 3px;
978
+ }
979
+
980
+ body.mobile .crafting-item-icon {
981
+ width: 36px;
982
+ height: 36px;
983
+ }
984
+
985
+ body.mobile .crafting-item-stats {
986
+ font-size: 9px;
987
+ margin-top: 4px;
965
988
  }
966
989
 
967
990
  body.mobile .crafting-item-stats .stats-header {
968
- font-size: 8px;
991
+ font-size: 9px;
969
992
  }
970
993
 
971
994
  body.mobile .crafting-item-description {
972
- font-size: 8px;
973
- margin-top: 3px;
995
+ font-size: 9px;
996
+ margin-top: 4px;
974
997
  }
975
- }
976
998
  </style>
@@ -375,93 +375,71 @@
375
375
  flex: 1;
376
376
  }
377
377
 
378
- /* Mobile and Small Screen Responsive */
379
- @media (max-width: 768px) {
380
- .dialogue-panel {
381
- bottom: max(16px, env(safe-area-inset-bottom, 16px));
382
- right: max(12px, env(safe-area-inset-right, 12px));
383
- width: min(100vw - 24px, calc(100vw - 2 * max(12px, env(safe-area-inset-right, 12px))));
384
- max-width: 340px;
385
- max-height: min(70vh, calc(100vh - 32px));
386
- }
387
-
388
- .dialogue-header {
389
- padding: 8px 12px;
390
- }
391
-
392
- .dialogue-npc-avatar {
393
- width: 28px;
394
- height: 28px;
395
- }
396
-
397
- .dialogue-npc-name {
398
- font-size: 11px;
399
- }
400
-
401
- .dialogue-npc-title {
402
- font-size: 9px;
403
- }
378
+ /* Mobile Responsive */
379
+ body.mobile .dialogue-panel {
380
+ bottom: 20px;
381
+ right: 20px;
382
+ width: auto;
383
+ max-width: 340px;
384
+ min-width: 280px;
385
+ max-height: calc(100vh - 40px);
386
+ }
404
387
 
405
- .dialogue-close {
406
- width: 18px;
407
- height: 18px;
408
- font-size: 10px;
409
- }
388
+ body.mobile .dialogue-header {
389
+ padding: 8px 12px;
390
+ border-radius: 8px 8px 0 0;
391
+ }
410
392
 
411
- .dialogue-content {
412
- padding: 10px;
413
- max-height: calc(min(60vh, calc(100vh - 80px)) - 50px);
414
- }
393
+ body.mobile .dialogue-container {
394
+ border-radius: 8px;
395
+ }
415
396
 
416
- .dialogue-message {
417
- padding: 8px;
418
- font-size: 11px;
419
- margin-bottom: 8px;
420
- }
397
+ body.mobile .dialogue-npc-avatar {
398
+ width: 32px;
399
+ height: 32px;
400
+ border-radius: 4px;
401
+ }
421
402
 
422
- .dialogue-option {
423
- padding: 6px 8px;
424
- font-size: 10px;
425
- }
403
+ body.mobile .dialogue-npc-name {
404
+ font-size: 12px;
405
+ }
426
406
 
427
- .dialogue-quest-icon {
428
- width: 14px;
429
- height: 14px;
430
- }
407
+ body.mobile .dialogue-npc-title {
408
+ font-size: 10px;
431
409
  }
432
410
 
433
- /* Very small screens (landscape phones, small devices) */
434
- @media (max-width: 480px) {
435
- .dialogue-panel {
436
- max-height: min(60vh, calc(100vh - 20px));
437
- max-width: 300px;
438
- }
411
+ body.mobile .dialogue-close {
412
+ width: 20px;
413
+ height: 20px;
414
+ font-size: 12px;
415
+ border-radius: 4px;
416
+ }
439
417
 
440
- .dialogue-content {
441
- max-height: calc(min(50vh, calc(100vh - 60px)) - 45px);
442
- padding: 8px;
443
- }
418
+ body.mobile .dialogue-content {
419
+ padding: 12px;
420
+ max-height: calc(100vh - 140px);
421
+ }
444
422
 
445
- .dialogue-message {
446
- padding: 6px;
447
- font-size: 10px;
448
- }
423
+ body.mobile .dialogue-content * {
424
+ overflow-y: scroll;
425
+ touch-action: pan-y !important;
426
+ }
449
427
 
450
- .dialogue-option {
451
- padding: 5px 6px;
452
- font-size: 9px;
453
- }
428
+ body.mobile .dialogue-message {
429
+ padding: 8px;
430
+ font-size: 11px;
431
+ margin-bottom: 8px;
432
+ border-radius: 4px;
433
+ }
454
434
 
455
- .dialogue-quest-icon {
456
- width: 12px;
457
- height: 12px;
458
- }
435
+ body.mobile .dialogue-option {
436
+ padding: 8px 10px;
437
+ font-size: 11px;
438
+ border-radius: 4px;
459
439
  }
460
440
 
461
- /* Ultra-wide screens - prevent dialogue from being too far left */
462
- @media (min-width: 1920px) {
463
- .dialogue-panel {
464
- right: max(20px, calc((100vw - 1200px) / 4));
465
- }
441
+ body.mobile .dialogue-quest-icon {
442
+ width: 14px;
443
+ height: 14px;
466
444
  }
467
445
  </style>