123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <div id="app" class="appBackground">
- <div class="container-fluid">
- <div class="row">
- <div
- class="col-2"
- v-if="!hideTest"
- style="background-color:lightgreen;"
- >
- <span class="title-medieval">For tests</span>
- <br />
- <button
- class="btn btn-primary custom-button"
- @click="test = 'app-menu'"
- >
- Enter Menu
- </button>
- <br />
- <br />
- <button
- class="btn btn-primary custom-button"
- @click="test = 'app-game'"
- >
- Enter Game
- </button>
- </div>
- <div class="col">
- <button
- style="font-size:8px"
- @click="
- hideTest = !hideTest;
- if (hideTest) test = '';
- "
- >
- Test
- </button>
- <keep-alive>
- <component :is="choseDisplay"></component>
- </keep-alive>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import AppMenu from './menu/AppMenu';
- import AppGame from './game/AppGame';
- import { mapGetters } from 'vuex';
- export default {
- name: 'App',
- data() {
- return {
- hideTest: true,
- test: ''
- };
- },
- components: {
- AppMenu,
- AppGame
- },
- computed: {
- ...mapGetters({
- isGameRunning: 'isGameRunning'
- }),
- choseDisplay() {
- if (this.test !== '') {
- return this.test;
- }
- if (!this.isGameRunning) {
- return 'app-menu';
- } else {
- return 'app-game';
- }
- }
- },
- beforeMount() {
- let user = localStorage.getItem('username');
- if (user) {
- console.log('user in storage, try to connect ! : ', user);
- this.$store
- .dispatch('menu/connect', user)
- .then(() => {
- let gameId = localStorage.getItem('gameId');
- if (gameId && gameId > -1) {
- console.log('gameId in storage, try to join ! : ', gameId);
- this.$store.dispatch('menu/joinOnlineGame', {
- id: gameId,
- isNew: false
- });
- }
- })
- .catch(() => {});
- }
- },
- created() {
- this.$store.watch(
- () => this.$store.getters['messages'],
- messages => {
- if (messages.length > 0) {
- let message = messages.pop();
- this.$bvToast.toast(message.text, {
- title: message.from,
- toaster: 'b-toaster-top-right',
- solid: true,
- variant: 'info',
- autoHideDelay: 10000,
- appendToast: true
- });
- }
- }
- );
- }
- };
- </script>
- <style scoped lang="scss">
- @import './styles/fonts/fonts.scss';
- .appBackground {
- position: absolute;
- height: 100%;
- width: 100%;
- background: url(./assets/Background.png) no-repeat center center fixed;
- -webkit-background-size: cover;
- -moz-background-size: cover;
- -o-background-size: cover;
- background-size: cover;
- overflow: hidden;
- }
- </style>
|