Better mobile support

This commit is contained in:
Hamcha 2019-09-23 16:18:55 +02:00
parent 4306045991
commit e67f49fb06
Signed by: hamcha
GPG key ID: 44AD3571EB09A39E

View file

@ -11,10 +11,10 @@
<header> <header>
<h1>Join someone's session</h1> <h1>Join someone's session</h1>
</header> </header>
<b-field label="Session ID"> <b-field label="Session ID" class="only-full">
<b-input v-model="joinSessionID"></b-input> <b-input v-model="joinSessionID"></b-input>
</b-field> </b-field>
<div class="center submit"> <div class="center submit only-full">
<b-button <b-button
type="is-primary" type="is-primary"
@click="join" @click="join"
@ -24,60 +24,37 @@
Join Join
</b-button> </b-button>
</div> </div>
<b-field class="only-mobile full">
<b-input placeholder="Session ID" v-model="joinSessionID"></b-input>
<p class="control">
<b-button type="is-primary" @click="join" :disabled="!canJoin">
Join
</b-button>
</p>
</b-field>
</section> </section>
<section id="host"> <section id="host">
<header> <header>
<h1>Host a new session</h1> <h1>Host a new session</h1>
</header> </header>
<b-field label="Session type" /> <div class="columns">
<b-field> <div class="column">
<b-radio-button <b-field label="Max players">
class="full-btn" <b-numberinput
v-model="hostType" controls-position="compact"
native-value="game" v-model="hostMaxPlayers"
> ></b-numberinput>
<span>Game</span>
</b-radio-button>
<b-radio-button
class="full-btn"
v-model="hostType"
native-value="draft"
>
<span>Draft</span>
</b-radio-button>
</b-field>
<div v-if="hostType == 'game'">
<!--TODO-->
</div>
<div v-if="hostType == 'draft'">
<b-field label="Draft type">
<b-select v-model="hostDraftType" placeholder="Select type">
<option value="set">Set draft</option>
<option value="cube">Cube (random) draft</option>
<option value="i8pcube">Cube (seeded) draft</option>
</b-select>
</b-field>
<b-field label="Set" v-if="hostDraftType == 'set'">
<b-select v-model="hostDraftSet" placeholder="Select set">
<option v-for="set in sets" :key="set" :value="set">
{{ setNames[set] }}
</option>
</b-select>
</b-field>
<b-field
label="Cube URL"
v-if="hostDraftType == 'cube' || hostDraftType == 'i8pcube'"
>
<b-input v-model="hostDraftCubeURL"></b-input>
</b-field> </b-field>
</div> </div>
<div class="column">
<b-field label="Password">
<b-input v-model="hostPassword"></b-input>
</b-field>
</div>
</div>
<div class="center"> <div class="center">
<b-button <b-button type="is-primary" @click="create" class="wide">
type="is-primary"
@click="create"
class="wide"
:disabled="!canHost"
>
Create Create
</b-button> </b-button>
</div> </div>
@ -143,6 +120,11 @@
margin: 10px auto; margin: 10px auto;
} }
.full {
width: 100%;
margin: 10px;
}
.center { .center {
width: 100%; width: 100%;
text-align: center; text-align: center;
@ -155,15 +137,20 @@
} }
} }
.only-mobile {
display: none;
}
@media (max-width: 500px) { @media (max-width: 500px) {
.body { .only-full {
grid-template: 120px 1fr 1fr /1fr; display: none;
#info,
#join,
#host {
grid-row: auto;
grid-column: auto;
} }
.only-mobile {
display: inherit;
}
.body {
display: flex;
flex-direction: column;
section { section {
padding: 10px; padding: 10px;
header h1 { header h1 {
@ -177,7 +164,8 @@
<script lang="ts"> <script lang="ts">
import { Component, Vue } from "vue-property-decorator"; import { Component, Vue } from "vue-property-decorator";
import TopNav from "@/components/Navigation/TopNav.vue"; import TopNav from "@/components/Navigation/TopNav.vue";
import { allSets, setNames } from "../mlpccg"; import { StartServerOptions } from "@/store/network/types";
import { Action } from "vuex-class";
@Component({ @Component({
components: { components: {
@ -186,14 +174,15 @@ import { allSets, setNames } from "../mlpccg";
}) })
export default class Lobby extends Vue { export default class Lobby extends Vue {
private playerName!: string; private playerName!: string;
private hostType!: string; private hostMaxPlayers!: number;
private hostDraftType!: string; private hostPassword!: string;
private hostDraftSet!: string;
private hostDraftCubeURL!: string;
private joinSessionID!: string; private joinSessionID!: string;
private sets!: string[]; private sets!: string[];
private setNames!: Record<string, string>; private setNames!: Record<string, string>;
@Action("startServer", { namespace: "network" })
private startServer!: (options: StartServerOptions) => void;
private data() { private data() {
return { return {
playerName: playerName:
@ -201,47 +190,26 @@ export default class Lobby extends Vue {
Math.random() Math.random()
.toString() .toString()
.slice(2, 8), .slice(2, 8),
hostType: "game", hostMaxPlayers: 8,
hostDraftType: "set", hostPassword: "",
hostDraftSet: "FF", joinSessionID: ""
hostDraftCubeURL: "",
joinSessionID: "",
sets: allSets,
setNames: setNames
}; };
} }
private async create() {} private async create() {
this.startServer({
playerInfo: {
name: this.playerName
},
roomInfo: {
max_players: 8,
password: ""
}
});
}
private async join() {} private async join() {}
private get canHost(): boolean {
switch (this.hostType) {
case "game":
return true;
case "draft":
switch (this.hostDraftType) {
case "set":
if (!this.sets.includes(this.hostDraftSet)) {
return false;
}
return true;
case "block":
//TODO
return false;
case "cube":
case "i8pcube":
if (this.hostDraftCubeURL == "") {
return false;
}
return true;
}
return false;
default:
return false;
}
}
private get canJoin(): boolean { private get canJoin(): boolean {
return this.joinSessionID != ""; return this.joinSessionID != "";
} }