| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- /**
- * Partiel : Barre latérale des outils (extrait de header.php)
- */
- ?>
- <div class="sidebar">
- <nav class="nav flex-column">
- <!-- Outils de dessin -->
- <div class="tool-group">
- <h6><i class="bi bi-brush me-1"></i>Historique</h6>
- <a class="nav-link" href="#" id="header-undoBtn">
- <i class="bi bi-arrow-counterclockwise me-2"></i>Annuler
- </a>
- <a class="nav-link" href="#" id="header-redoBtn">
- <i class="bi bi-arrow-clockwise me-2"></i>Rétablir
- </a>
- <hr>
- <a class="nav-link" href="#" id="selectTool">
- <i class="bi bi-cursor me-2"></i>Sélection
- </a>
- </div>
- <!-- Options de type de tuile (visible quand une tuile est sélectionnée) -->
- <div class="tool-group" id="tile-type-tool" style="display:none;">
- <h6><i class="bi bi-grid-1x2-fill me-1"></i>Type de tuile</h6>
- <div id="tileTypeOptions" class="d-flex flex-column gap-2">
- <?php
- // Récupérer les définitions de tuiles depuis les données de la vue
- $tileDefinitions = [];
- if (isset($map_data) && isset($map_data['tileDefinitions'])) {
- $tileDefinitions = $map_data['tileDefinitions'];
- } elseif (isset($GLOBALS['view_data']['map_data']['tileDefinitions'])) {
- $tileDefinitions = $GLOBALS['view_data']['map_data']['tileDefinitions'];
- }
- // Si aucune définition trouvée, utiliser des valeurs par défaut
- if (empty($tileDefinitions)) {
- $tileDefinitions = [
- ['id' => 'empty', 'name' => 'Vide', 'color' => '#ffffff'],
- ['id' => 'grass', 'name' => 'Herbe', 'color' => '#90EE90']
- ];
- }
- foreach ($tileDefinitions as $tileDef) {
- $tileId = $tileDef['id'];
- $tileName = $tileDef['name'];
- $tileColor = $tileDef['color'] ?? '#ffffff';
- $tileAsset = $tileDef['asset'] ?? null;
- echo '<div class="form-check tile-type-option">' . "\n";
- echo ' <input class="form-check-input tile-type-radio" type="radio" name="tileType" id="tileType_' . htmlspecialchars($tileId) . '" value="' . htmlspecialchars($tileId) . '">' . "\n";
- echo ' <label class="form-check-label d-flex align-items-center gap-2" for="tileType_' . htmlspecialchars($tileId) . '">' . "\n";
- if ($tileAsset) {
- // Utiliser l'asset SVG hexagonal
- $svgPath = '/Volumes/SSD-T1/mamp-pro/map-generator/public' . $tileAsset;
- if (file_exists($svgPath)) {
- $svgContent = file_get_contents($svgPath);
- // Adapter la taille pour les boutons (plus petit que les tuiles complètes)
- $svgContent = preg_replace('/width="[^"]*"/', 'width="32"', $svgContent);
- $svgContent = preg_replace('/height="[^"]*"/', 'height="28"', $svgContent);
- echo ' ' . $svgContent . "\n";
- } else {
- // Fallback vers un cercle coloré si le SVG n'existe pas
- echo ' <div style="width: 32px; height: 28px; background-color: ' . htmlspecialchars($tileColor) . '; border: 1px solid #333; border-radius: 4px;"></div>' . "\n";
- }
- } else {
- // Fallback vers un cercle coloré
- echo ' <div style="width: 32px; height: 28px; background-color: ' . htmlspecialchars($tileColor) . '; border: 1px solid #333; border-radius: 4px;"></div>' . "\n";
- }
- echo ' <span>' . htmlspecialchars($tileName) . '</span>' . "\n";
- echo ' </label>' . "\n";
- echo '</div>' . "\n";
- }
- ?>
- </div>
- </div>
- </nav>
- </div>
|