Skip to content
Snippets Groups Projects
Index.vue 3.47 KiB
Newer Older
  • Learn to ignore specific revisions
  • Griefed's avatar
    Griefed committed
    <template>
    
    Trungel's avatar
    Trungel committed
      <span v-if="store.state.lttMap">
        <span v-for="(xRow, index) in store.state.lttMap" :key="index">
    
    Trungel's avatar
    Trungel committed
          <div class="row no-wrap"
    
    Trungel's avatar
    Trungel committed
            v-bind:class="{
              firstRow: (index == 0),
              moveup: (index !=0),
    
    Trungel's avatar
    Trungel committed
              shifted: (index != 0 && !(index%2))
    
    Trungel's avatar
    Trungel committed
            }"
          >
            <Tile
              v-for="(tile, i) in xRow"
    
    Trungel's avatar
    Trungel committed
              :tile="tile"
              :typeValue="tile.typeId"
              @update:typeValue="tile.typeId = $event"
    
    Trungel's avatar
    Trungel committed
              v-bind:id="tile.x+'_'+tile.y"
    
    Trungel's avatar
    Trungel committed
              :class="{tileMl: (i!=0)?1:0}"
              v-bind:style="{ zIndex: 1000,
                            }"
    
    Trungel's avatar
    Trungel committed
              v-bind:key="i">
              </Tile>
    
    Trungel's avatar
    Trungel committed
          </div>
        </span>
      </span>
    
    Trungel's avatar
    Trungel committed
      <span v-else>
    
        <div class="row no-wrap q-pa-md absolute-center">
          <q-card>
            <q-card-section>
                <div class="column" style="width: 600px;">
                  <div class="text-h6 q-mb-md text-black">New Map Dimensions</div>
                  <q-item>
                    <q-item-section avatar>
                      <q-icon size="30px" color="secondary" name="mdi-arrow-expand-horizontal" />
                    </q-item-section>
                    <q-item-section>
                      <q-slider v-model="store.state.mapSizeX" :min="1" :max="101" label color="secondary" :step="1" label-always/>
                    </q-item-section>
                  </q-item>
    
                  <q-item>
                    <q-item-section avatar>
                      <q-icon size="30px" color="secondary" name="mdi-arrow-expand-vertical" />
                    </q-item-section>
                    <q-item-section>
                      <q-slider v-model="store.state.mapSizeY" :min="1" :max="101" label color="secondary" :step="1" label-always/>
                    </q-item-section>
                  </q-item>
                  <q-btn class="q-mr-xs" color="secondary" label="Generate New Map" @click='createMap()'>
                    <q-tooltip :disable="$q.platform.is.mobile">
                      Generate new map with size set above
                    </q-tooltip>
                  </q-btn>
                </div>
              </q-card-section>
    
              <q-card-section>
                <div class="column">
                  <div class="text-h6 q-mb-md text-black">Load Existing Map</div>
                  <q-input
                    v-model="mapString"
                    filled
                    placeholder="Paste Map Data"
                    type="textarea"
                    input-class="pastCodeArea"
                  ></q-input>
                  <q-btn class="q-mr-xs" color="secondary" label="Load Map From Filedata" @click='loadMapData()'>
                    <q-tooltip :disable="$q.platform.is.mobile">
                      Load Map From Data
                    </q-tooltip>
                  </q-btn>
                </div>
            </q-card-section>
          </q-card>
    
    Trungel's avatar
    Trungel committed
        </div>
      </span>
    
    Trungel's avatar
    Trungel committed
    
    
    Griefed's avatar
    Griefed committed
    </template>
    
    <script>
    
    Trungel's avatar
    Trungel committed
    import { defineComponent, inject, ref } from 'vue';
    
    Griefed's avatar
    Griefed committed
    import Tile from "../components/Tile.vue";
    
    export default defineComponent({
        setup() {
    
    Trungel's avatar
    Trungel committed
    
          const store = inject('store');
    
    
    Trungel's avatar
    Trungel committed
          var mapString = ref('')
    
          const loadMapData = function() {
            store.methods.loadMap(JSON.parse(mapString.value));
          };
    
    
    Trungel's avatar
    Trungel committed
          const createMap= function(){
            store.methods.generateMap();
          };
    
    
    Griefed's avatar
    Griefed committed
          return {
    
    Trungel's avatar
    Trungel committed
            mapString,
    
    Trungel's avatar
    Trungel committed
            store,
            createMap,
    
    Trungel's avatar
    Trungel committed
            loadMapData
    
    Trungel's avatar
    Trungel committed
          }
        },
    
    Trungel's avatar
    Trungel committed
    
    
    Trungel's avatar
    Trungel committed
        methods:{
    
    Trungel's avatar
    Trungel committed
    
    
    Griefed's avatar
    Griefed committed
        },
        components: {
          Tile
        },
      }
    )
    </script>
    
    <style>
    
    Griefed's avatar
    Griefed committed
    .shifted {
    
    Griefed's avatar
    Griefed committed
      margin-left: 49px;
    }
    
    
    Trungel's avatar
    Trungel committed
    .tileMl {
      margin-left: -2px;
    }
    
    
    Griefed's avatar
    Griefed committed
    .moveup {
    
    Griefed's avatar
    Griefed committed
    }
    </style>