home.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?php
  2. /**
  3. * Vue de la page d'accueil
  4. */
  5. include __DIR__ . '/partials/header.php';
  6. ?>
  7. <main class="main-content">
  8. <div class="container-fluid">
  9. <div class="row">
  10. <div class="col-12">
  11. <!-- Zone de travail principale -->
  12. <div class="card">
  13. <div class="card-header">
  14. <h5 class="card-title mb-0">
  15. <i class="bi bi-pencil-square me-2"></i>
  16. Éditeur de carte
  17. </h5>
  18. </div>
  19. <div class="card-body">
  20. <?php
  21. $loaded_map = $loaded_map ?? ($GLOBALS['view_data']['loaded_map'] ?? null);
  22. $map_data = $map_data ?? ($GLOBALS['view_data']['map_data'] ?? null);
  23. $load_error = $load_error ?? ($GLOBALS['view_data']['load_error'] ?? null);
  24. ?>
  25. <?php if (isset($load_error) && $load_error): ?>
  26. <!-- Message d'erreur de chargement -->
  27. <div class="alert alert-danger">
  28. <i class="bi bi-exclamation-triangle me-2"></i><?php echo htmlspecialchars($load_error); ?>
  29. </div>
  30. <div class="text-center mt-3">
  31. <a href="/projects" class="btn btn-primary">Voir toutes les cartes disponibles</a>
  32. </div>
  33. <?php elseif (isset($loaded_map) && $loaded_map): ?>
  34. <!-- Interface de la carte chargée -->
  35. <div class="alert alert-success">Carte chargée avec succès !</div>
  36. <!-- Interface de la carte chargée -->
  37. <div class="map-editor-container">
  38. <!-- Barre d'outils de la carte -->
  39. <div class="map-toolbar d-flex justify-content-between align-items-center mb-3">
  40. <div class="d-flex align-items-center gap-2">
  41. <h6 class="mb-0">
  42. <i class="bi bi-map me-2"></i><?php echo htmlspecialchars($map_data['name']); ?>
  43. </h6>
  44. <span class="badge bg-info">
  45. <?php echo $map_data['width']; ?> × <?php echo $map_data['height']; ?>
  46. </span>
  47. </div>
  48. <div class="d-flex align-items-center gap-2">
  49. <small class="text-muted">
  50. Zoom: <span id="zoomLevel">100</span>%
  51. </small>
  52. <div class="btn-group btn-group-sm">
  53. <button class="btn btn-outline-secondary" id="zoomOut" title="Zoom arrière">
  54. <i class="bi bi-zoom-out"></i>
  55. </button>
  56. <button class="btn btn-outline-secondary" id="zoomIn" title="Zoom avant">
  57. <i class="bi bi-zoom-in"></i>
  58. </button>
  59. <button class="btn btn-outline-secondary" id="fitToScreen" title="Adapter à l'écran">
  60. <i class="bi bi-arrows-fullscreen"></i>
  61. </button>
  62. </div>
  63. </div>
  64. </div>
  65. <!-- Zone de la carte interactive -->
  66. <div class="map-canvas-container border" style="position: relative; overflow: hidden; height: 600px; background-color: #f8f9fa;">
  67. <div id="mapCanvas" style="position: absolute; top: 0; left: 0; cursor: grab; z-index: 1;">
  68. <!-- La carte sera rendue ici via JavaScript -->
  69. </div>
  70. <!-- Indicateur de chargement -->
  71. <div id="mapLoading" class="d-flex align-items-center justify-content-center" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255,255,255,0.8); z-index: 10;">
  72. <div class="text-center">
  73. <div class="spinner-border text-primary mb-2" role="status">
  74. <span class="visually-hidden">Chargement...</span>
  75. </div>
  76. <p class="mb-0">Chargement de la carte...</p>
  77. </div>
  78. </div>
  79. </div>
  80. <!-- Informations de la tuile sélectionnée -->
  81. <div id="tileInfo" class="mt-3 p-3 bg-light rounded" style="display: none;">
  82. <h6 class="mb-2">
  83. <i class="bi bi-info-circle me-1"></i>Propriétés de la parcelle
  84. </h6>
  85. <div class="row">
  86. <div class="col-md-6">
  87. <small class="text-muted">Position</small>
  88. <p class="mb-1" id="tilePosition">Q: 0, R: 0</p>
  89. </div>
  90. <div class="col-md-6">
  91. <small class="text-muted">Type</small>
  92. <p class="mb-1" id="tileType">Vide</p>
  93. </div>
  94. </div>
  95. <div id="tileProperties" class="mt-2">
  96. <!-- Les propriétés de la tuile seront affichées ici -->
  97. </div>
  98. </div>
  99. </div>
  100. <?php else: ?>
  101. <!-- Zone indiquant qu'aucun projet n'est chargé -->
  102. <div class="alert alert-info">Aucune carte chargée</div>
  103. <div class="editor-empty border d-flex align-items-center justify-content-center" style="width:100%; height:600px; background-color:#e9ecef;">
  104. <div class="text-center">
  105. <!-- Illustration SVG représentant une carte vide -->
  106. <svg role="img" aria-label="Illustration : cadriage avec point d'attention" width="200" height="140" viewBox="0 0 200 140" xmlns="http://www.w3.org/2000/svg" class="mx-auto d-block">
  107. <defs>
  108. <linearGradient id="g" x1="0" x2="1">
  109. <stop offset="0" stop-color="#f8f9fa"/>
  110. <stop offset="1" stop-color="#e9ecef"/>
  111. </linearGradient>
  112. </defs>
  113. <rect x="8" y="12" width="184" height="116" rx="8" fill="url(#g)" stroke="#ced4da" />
  114. <!-- Grid lines -->
  115. <g stroke="#adb5bd" stroke-width="1">
  116. <line x1="20" y1="20" x2="180" y2="20"/>
  117. <line x1="20" y1="40" x2="180" y2="40"/>
  118. <line x1="20" y1="60" x2="180" y2="60"/>
  119. <line x1="20" y1="80" x2="180" y2="80"/>
  120. <line x1="20" y1="100" x2="180" y2="100"/>
  121. <line x1="20" y1="120" x2="180" y2="120"/>
  122. <line x1="20" y1="20" x2="20" y2="120"/>
  123. <line x1="60" y1="20" x2="60" y2="120"/>
  124. <line x1="100" y1="20" x2="100" y2="120"/>
  125. <line x1="140" y1="20" x2="140" y2="120"/>
  126. <line x1="180" y1="20" x2="180" y2="120"/>
  127. </g>
  128. <!-- Point d'attention -->
  129. <rect x="95" y="55" width="10" height="10" fill="#dc3545" stroke="#b02a37" rx="2"/>
  130. <text x="100" y="50" text-anchor="middle" font-size="8" fill="#dc3545" font-weight="bold">!</text>
  131. </svg>
  132. <!-- Texte principal -->
  133. <h5 class="mt-3 mb-1">Aucun projet chargé</h5>
  134. <!-- Explication -->
  135. <p class="text-muted small mb-3">Créez un nouveau projet ou chargez-en un existant pour commencer à éditer une carte.</p>
  136. <!-- Actions rapides -->
  137. <div class="d-flex justify-content-center gap-2">
  138. <a href="/projects/new" class="btn btn-primary btn-sm">Nouveau projet</a>
  139. <a href="/projects" class="btn btn-outline-secondary btn-sm">Charger un projet</a>
  140. </div>
  141. <!-- Guide de chargement -->
  142. <div class="mt-4 p-3 bg-light rounded">
  143. <h6 class="mb-2">
  144. <i class="bi bi-lightbulb me-1"></i>Comment charger une carte ?
  145. </h6>
  146. <ol class="small mb-0 text-muted">
  147. <li>Allez dans <a href="/projects">Mes projets</a> pour voir vos cartes</li>
  148. <li>Notez l'ID de la carte (affiché à côté du nom)</li>
  149. <li>Ajoutez <code>?load=ID</code> à l'URL (ex: <code>https://map-generator/?load=5</code>)</li>
  150. </ol>
  151. </div>
  152. </div>
  153. </div>
  154. <?php endif; ?>
  155. </div>
  156. </div>
  157. <?php include __DIR__ . '/partials/project-info.php'; ?>
  158. </div>
  159. </div>
  160. </div>
  161. </main>
  162. <?php
  163. include __DIR__ . '/partials/footer.php';
  164. ?>
  165. <?php if ($loaded_map): ?>
  166. <script>
  167. // Données de la carte
  168. const mapData = <?php echo json_encode($map_data); ?>;
  169. const mapWidth = mapData.width;
  170. const mapHeight = mapData.height;
  171. </script>
  172. <script src="/assets/js/editor/map-editor.js"></script>
  173. <?php endif; ?>