From 6a5a994570abccae6b0ee6aa1612d02cfab170d2 Mon Sep 17 00:00:00 2001
From: Trungel <29035983+Trungel@users.noreply.github.com>
Date: Mon, 27 Sep 2021 23:44:07 +0200
Subject: [PATCH] displaying viewCenter und viewRadius

---
 src/components/Tile.vue | 100 ++++++++++++++++++++++++++++++++++++++--
 src/pages/Index.vue     |   7 +--
 2 files changed, 97 insertions(+), 10 deletions(-)

diff --git a/src/components/Tile.vue b/src/components/Tile.vue
index 8fa5c88..6ded551 100644
--- a/src/components/Tile.vue
+++ b/src/components/Tile.vue
@@ -1,8 +1,9 @@
 <template>
 
-   <div id="parent" class="hexagon" :class="tile.typeId">
-    <div class="hexTop"></div>
-    <div class="hexBottom"></div>
+   <div id="parent" class="hexagon"
+    :class="[tile.typeId, ((tile.x == store.state.centerX) && (tile.y == store.state.centerY))?'centerTile':'', isViewRadiusBorder()]">
+    <div class="hexTop" :class="((tile.x == store.state.centerX) && (tile.y == store.state.centerY))?'centerTop':''"></div>
+    <div class="hexBottom" :class="((tile.x == store.state.centerX) && (tile.y == store.state.centerY))?'centerBottom':''"></div>
 
     <q-btn-dropdown
       class="buttonshift without-icon custom-width"
@@ -33,16 +34,43 @@
 </template>
 
 <script>
-import {ref} from "vue";
+import {inject, ref} from "vue";
 
 export default {
   props:{
     tile: Object,
     typeValue: String
   },
-  setup () {
+  setup (props) {
     var types = ["barren", "clay", "desert", "fish", "forest", "grass", "ice", "iron", "mountain", "salt", "stone", "water", "wheat", "wool"];
+    const store = inject('store');
+
+    const isViewRadiusBorder = function() {
+      var borders = [];
+      //leftBorder
+      if( props.tile.x == (this.store.state.centerX-this.store.state.radiusX) &&
+          ((this.store.state.centerY-this.store.state.radiusY) <= props.tile.y && props.tile.y <= (this.store.state.centerY+this.store.state.radiusY))){
+            borders.push("viewBorderLeft");
+      }
+      if( props.tile.x == (this.store.state.centerX+this.store.state.radiusX) &&
+          ((this.store.state.centerY-this.store.state.radiusY) <= props.tile.y && props.tile.y <= (this.store.state.centerY+this.store.state.radiusY))){
+            borders.push("viewBorderRight")
+      }
+      if( props.tile.y == (this.store.state.centerY+this.store.state.radiusY) &&
+          ((this.store.state.centerX-this.store.state.radiusX) <= props.tile.x && props.tile.x <= (this.store.state.centerX+this.store.state.radiusX))){
+            borders.push("viewBorderTop")
+      }
+      if( props.tile.y == (this.store.state.centerY-this.store.state.radiusY) &&
+          ((this.store.state.centerX-this.store.state.radiusX) <= props.tile.x && props.tile.x <= (this.store.state.centerX+this.store.state.radiusX))){
+            borders.push("viewBorderBottom")
+      }
+
+      return borders;
+    }
+
     return {
+      isViewRadiusBorder,
+      store,
       types,
       menuState: ref(false),
       label: 'grass',
@@ -88,6 +116,12 @@ button.without-icon i {
   border-right: solid 3px #333333;
 }
 
+.centerTile {
+  z-index: 1002;
+  border-left: solid 3px red;
+  border-right: solid 3px red;
+}
+
 .hexTop,
 .hexBottom {
   position: absolute;
@@ -149,6 +183,52 @@ button.without-icon i {
   background: inherit;
 }
 
+.viewBorderLeft {
+  z-index: 1001;
+  border-left: dashed 3px blue;
+}
+
+.viewBorderRight {
+  z-index: 1001;
+  border-right: dashed 3px blue;
+}
+
+.viewBorderTop {
+  z-index: 1001;
+  .hexTop {
+    border-top: dashed 3px blue;
+    border-right: dashed 3px blue;
+  }
+}
+.viewBorderBottom {
+  z-index: 1001;
+  .hexBottom {
+    border-bottom: dashed 3px blue;
+    border-left: dashed 3px blue;
+  }
+}
+
+.notShifted{
+  .viewBorderLeft{
+    .hexTop{
+      border-top: dashed 3px blue;
+    }
+    .hexBottom{
+      border-left: dashed 3px blue;
+    }
+  }
+}
+.shifted{
+  .viewBorderRight{
+    .hexTop{
+      border-right: dashed 3px blue;
+    }
+    .hexBottom{
+      border-bottom: dashed 3px blue;
+    }
+  }
+}
+
 .barren {
   background-image: url("../assets/tiles/barren_tile.webp");
   button {
@@ -249,4 +329,14 @@ button.without-icon i {
     color: black;
   }
 }
+
+.centerTop {
+  border-top: solid 4.2426px red;
+  border-right: solid 4.2426px red;
+}
+
+.centerBottom {
+  border-bottom: solid 4.2426px red;
+  border-left: solid 4.2426px red;
+}
 </style>
diff --git a/src/pages/Index.vue b/src/pages/Index.vue
index a2f1199..2249a63 100644
--- a/src/pages/Index.vue
+++ b/src/pages/Index.vue
@@ -2,11 +2,10 @@
   <span v-if="store.state.lttMap">
     <span v-for="(xRow, index) in store.state.lttMap" :key="index">
       <div class="row no-wrap"
-        v-bind:class="{
+        v-bind:class="[{
           firstRow: (index == 0),
           moveup: (index !=0),
-          shifted: (index != 0 && !(index%2))
-        }"
+        }, (index != 0 && !(index%2))?'shifted':'notShifted']"
       >
         <Tile
           v-for="(tile, i) in xRow"
@@ -15,8 +14,6 @@
           @update:typeValue="tile.typeId = $event"
           v-bind:id="tile.x+'_'+tile.y"
           :class="{tileMl: (i!=0)?1:0}"
-          v-bind:style="{ zIndex: 1000,
-                        }"
           v-bind:key="i">
           </Tile>
       </div>
-- 
GitLab