Skip to content

Commit

Permalink
feat: support create with forge
Browse files Browse the repository at this point in the history
Former-commit-id: 59d14f5
  • Loading branch information
ci010 committed Jul 15, 2019
1 parent ce78d1a commit 60549aa
Showing 1 changed file with 94 additions and 39 deletions.
133 changes: 94 additions & 39 deletions src/renderer/windows/main/components/AddProfileWizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<small>{{$t('optional')}}</small>
</v-stepper-step>
<v-divider></v-divider>
<v-stepper-step editable step="3">
{{$t('profile.forgeSetting')}}
<small>{{$t('optional')}}</small>
</v-stepper-step>
</v-stepper-header>

<v-stepper-items>
Expand All @@ -28,13 +24,13 @@
required></v-text-field>
</v-flex>
<v-flex d-flex xs4>
<!-- <version-menu @value="mcversion = $event">
<version-menu @value="mcversion = $event">
<template v-slot="{ on }">
<v-text-field dark append-icon="arrow" persistent-hint :hint="$t('profile.versionHint')"
v-model="mcversion" :label="$t('minecraft.version')" :readonly="true" @click:append="on.keydown"
v-on="on"></v-text-field>
</template>
</version-menu> -->
</version-menu>
</v-flex>
<v-flex d-flex xs12>
<v-text-field dark v-model="description" persistent-hint :hint="$t('profile.descriptionHint')"
Expand All @@ -55,34 +51,43 @@
</v-btn>
</v-layout>
</v-stepper-content>

<v-stepper-content step="2">
<v-card class="mb-5" color="grey lighten-1" height="200px">

</v-card>

<v-layout>
<v-btn flat @click="quit">{{$t('cancel')}}</v-btn>
<v-spacer></v-spacer>
<v-btn flat @click="step = 3">
{{$t('next')}}
</v-btn>
<v-btn color="primary" :disabled="!valid" @click="doCreate">
{{$t('create')}}
</v-btn>
</v-layout>
</v-stepper-content>

<v-stepper-content step="3">
<v-card class="mb-5" color="grey lighten-1" height="200px"></v-card>
<v-form v-model="valid" lazy-validation style="height: 100%;">
<v-container grid-list fill-height style="overflow: auto;">
<v-layout row wrap>
<v-flex d-flex xs6>
<v-select class="java-select" hide-details :item-text="getJavaText" :item-value="getJavaValue"
prepend-inner-icon="add" v-model="javaLocation" :label="$t('java.location')" :items="javas"
required :menu-props="{ auto: true, overflowY: true }"></v-select>
</v-flex>
<v-flex d-flex xs3>
<v-text-field hide-details type="number" v-model="minMemory" :label="$t('java.minMemory')"
required></v-text-field>
</v-flex>
<v-flex d-flex xs3>
<v-text-field hide-details type="number" v-model="maxMemory" :label="$t('java.maxMemory')"
required></v-text-field>
</v-flex>
<v-flex d-flex xs6>
<forge-version-menu @value="forgeVersion = $event.version" :mcversion="mcversion">
<template v-slot="{ on }">
<v-text-field dark append-icon="arrow" persistent-hint :hint="$t('profile.versionHint')"
v-model="forgeVersion" :label="$t('forge.version')" :readonly="true" @click:append="on.keydown"
v-on="on"></v-text-field>
</template>
</forge-version-menu>
</v-flex>
</v-layout>
</v-container>
</v-form>

<v-layout>
<v-btn flat @click="quit">{{$t('cancel')}}</v-btn>
<v-spacer></v-spacer>
<v-btn flat @click="step = 1">
<!-- <v-btn flat @click="step = 3">
{{$t('next')}}
</v-btn>
<v-btn color="primary" :disabled="!valid" @click="doCreate">
</v-btn> -->
<v-btn color="primary" :disabled="!valid || name === '' || mcversion === ''" @click="doCreate">
{{$t('create')}}
</v-btn>
</v-layout>
Expand All @@ -95,24 +100,27 @@
export default {
data: function () {
const release = this.$repo.getters['minecraftRelease'].id;
const forge = release ? this.$repo.getters.forgeRecommendedOf(release) : '';
const forgeVersion = forge ? forge.version : '';
return {
step: 0,
step: 1,
valid: false,
mcversion: this.$repo.getters['minecraftRelease'].id,
javaValid: true,
maxMemory: 1024,
minMemory: 1024,
name: '',
mcversion: release,
forgeVersion,
javaLocation: this.$repo.getters['defaultJava'],
memoryRule: [v => Number.isInteger(v)],
maxMemory: 2048,
minMemory: 1024,
author: this.$repo.state.user.name,
description: '',
name: '',
javaValid: true,
memoryRule: [v => Number.isInteger(v)],
nameRules: [
v => !!v || this.$t('profile.requireName')
],
author: this.$repo.state.user.name,
description: '',
}
},
computed: {
Expand All @@ -122,10 +130,46 @@ export default {
versions() {
return Object.keys(this.$repo.state.version.minecraft.versions);
},
javas() {
return this.$repo.state.java.all;
},
},
components: {
props: {
show: {
type: Boolean,
default: false,
},
},
watch: {
show() {
if (this.show) {
this.init();
}
},
},
methods: {
init() {
const release = this.$repo.getters['minecraftRelease'].id;
const forge = release ? this.$repo.getters.forgeRecommendedOf(release) : '';
const forgeVersion = forge ? forge.version : '';
this.forgeVersion = forgeVersion;
this.mcversion = release;
this.step = 1;
this.name = '';
this.author = this.$repo.state.user.name;
this.description = '';
const defaultJava = this.$repo.getters.defaultJava;
this.javaLocation = this.javas.find(j => j.path === defaultJava.path);
this.minMemory = 1024;
this.maxMemory = 2048;
},
getJavaValue(java) {
return java;
},
getJavaText(java) {
return `JRE${java.majorVersion}, ${java.path}`
},
quit() {
this.$emit('quit');
},
Expand All @@ -139,7 +183,11 @@ export default {
maxMemory: this.maxMemory,
java: this.javaLocation,
mcversion: this.mcversion,
forge: {
version: this.forgeVersion,
},
}).then(() => {
this.init();
this.$router.replace('/');
});
},
Expand All @@ -148,6 +196,13 @@ export default {
</script>

<style>
.java-select .v-select__selection {
white-space: nowrap;
overflow-x: hidden;
overflow-y: hidden;
max-width: 240px;
}
.v-stepper__step span {
margin-right: 12px !important;
}
Expand Down

0 comments on commit 60549aa

Please sign in to comment.