tools-sidebar.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Partiel : Barre latérale des outils (extrait de header.php)
  4. */
  5. ?>
  6. <div class="sidebar">
  7. <nav class="nav flex-column">
  8. <!-- Outils de dessin -->
  9. <div class="tool-group">
  10. <h6><i class="bi bi-brush me-1"></i>Historique</h6>
  11. <a class="nav-link" href="#" id="header-undoBtn">
  12. <i class="bi bi-arrow-counterclockwise me-2"></i>Annuler
  13. </a>
  14. <a class="nav-link" href="#" id="header-redoBtn">
  15. <i class="bi bi-arrow-clockwise me-2"></i>Rétablir
  16. </a>
  17. <hr>
  18. <a class="nav-link" href="#" id="selectTool">
  19. <i class="bi bi-cursor me-2"></i>Sélection
  20. </a>
  21. </div>
  22. <!-- Options de type de tuile (visible quand une tuile est sélectionnée) -->
  23. <div class="tool-group" id="tile-type-tool" style="display:none;">
  24. <h6><i class="bi bi-grid-1x2-fill me-1"></i>Type de tuile</h6>
  25. <div id="tileTypeOptions" class="d-flex flex-column gap-2">
  26. <?php
  27. // Récupérer les définitions de tuiles depuis les données de la vue
  28. $tileDefinitions = [];
  29. if (isset($map_data) && isset($map_data['tileDefinitions'])) {
  30. $tileDefinitions = $map_data['tileDefinitions'];
  31. } elseif (isset($GLOBALS['view_data']['map_data']['tileDefinitions'])) {
  32. $tileDefinitions = $GLOBALS['view_data']['map_data']['tileDefinitions'];
  33. }
  34. // Si aucune définition trouvée, utiliser des valeurs par défaut
  35. if (empty($tileDefinitions)) {
  36. $tileDefinitions = [
  37. ['id' => 'empty', 'name' => 'Vide', 'color' => '#ffffff'],
  38. ['id' => 'grass', 'name' => 'Herbe', 'color' => '#90EE90']
  39. ];
  40. }
  41. foreach ($tileDefinitions as $tileDef) {
  42. $tileId = $tileDef['id'];
  43. $tileName = $tileDef['name'];
  44. $tileColor = $tileDef['color'] ?? '#ffffff';
  45. $tileAsset = $tileDef['asset'] ?? null;
  46. echo '<div class="form-check tile-type-option">' . "\n";
  47. echo ' <input class="form-check-input tile-type-radio" type="radio" name="tileType" id="tileType_' . htmlspecialchars($tileId) . '" value="' . htmlspecialchars($tileId) . '">' . "\n";
  48. echo ' <label class="form-check-label d-flex align-items-center gap-2" for="tileType_' . htmlspecialchars($tileId) . '">' . "\n";
  49. if ($tileAsset) {
  50. // Utiliser l'asset SVG hexagonal
  51. $svgPath = '/Volumes/SSD-T1/mamp-pro/map-generator/public' . $tileAsset;
  52. if (file_exists($svgPath)) {
  53. $svgContent = file_get_contents($svgPath);
  54. // Adapter la taille pour les boutons (plus petit que les tuiles complètes)
  55. $svgContent = preg_replace('/width="[^"]*"/', 'width="32"', $svgContent);
  56. $svgContent = preg_replace('/height="[^"]*"/', 'height="28"', $svgContent);
  57. echo ' ' . $svgContent . "\n";
  58. } else {
  59. // Fallback vers un cercle coloré si le SVG n'existe pas
  60. echo ' <div style="width: 32px; height: 28px; background-color: ' . htmlspecialchars($tileColor) . '; border: 1px solid #333; border-radius: 4px;"></div>' . "\n";
  61. }
  62. } else {
  63. // Fallback vers un cercle coloré
  64. echo ' <div style="width: 32px; height: 28px; background-color: ' . htmlspecialchars($tileColor) . '; border: 1px solid #333; border-radius: 4px;"></div>' . "\n";
  65. }
  66. echo ' <span>' . htmlspecialchars($tileName) . '</span>' . "\n";
  67. echo ' </label>' . "\n";
  68. echo '</div>' . "\n";
  69. }
  70. ?>
  71. </div>
  72. </div>
  73. </nav>
  74. </div>