aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/components/PlayButton.vue
blob: ba40d68e32309e06bb8f6fa6e16c06d2c2b5398d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<script lang="ts">
import { defineComponent } from 'vue';
import { NorthstarState } from '../utils/NorthstarState';
import { ReleaseCanal } from '../utils/ReleaseCanal';

export default defineComponent({
    name: 'PlayButton',
    computed: {
        currentCanal: {
            get(): ReleaseCanal {
                return this.$store.state.northstar_release_canal;
            },
            set(value: ReleaseCanal) {
                if (value !== this.currentCanal) {
                    this.$store.commit('toggleReleaseCandidate');
                }
            }
        },
        playButtonLabel(): string {
            if (this.$store.state.northstar_is_running) {
                return this.$t("play.button.northstar_is_running");
            }

            switch (this.$store.state.northstar_state) {
                case NorthstarState.GAME_NOT_FOUND:
                    return this.$t("play.button.select_game_dir");
                case NorthstarState.INSTALL:
                    return this.$t("play.button.install");
                case NorthstarState.INSTALLING:
                    return this.$t("play.button.installing");
                case NorthstarState.MUST_UPDATE:
                    return this.$t("play.button.update");
                case NorthstarState.UPDATING:
                    return this.$t("play.button.updating");
                case NorthstarState.READY_TO_PLAY:
                    return this.$t("play.button.ready_to_play");

                default:
                    return "";
            }
        },
        northstarIsRunning(): boolean {
            return this.$store.state.northstar_is_running;
        },
        options(): { key: string, value: string }[] {
            return Object.keys(ReleaseCanal).map(function (v) {
                return {
                    key: v,
                    value: Object.keys(ReleaseCanal)[Object.values(ReleaseCanal).indexOf(v)]
                }
            });
        },
        selectOptions(): { label: string, options: { value: ReleaseCanal, label: string }[] }[] {
            return [
                {
                    label: 'Beta',
                    options: [
                        {
                            value: ReleaseCanal.RELEASE_CANDIDATE,
                            label: this.$t('channels.names.NorthstarReleaseCandidate'),
                        },
                    ]
                },
                {
                    label: 'Stable',
                    options: [
                        {
                            value: ReleaseCanal.RELEASE,
                            label: 'Northstar',
                        },
                    ]
                }
            ];
        },
        showReleaseSwitch(): boolean {
            return this.$store.state.enableReleasesSwitch;
        },

        /**
         * Button has rounded edges on its right only if releases switching is enabled.
         */
        buttonRadiusStyle(): string {
            return this.showReleaseSwitch
                ? 'border-radius: 2px 0 0 2px;'
                : 'border-radius: 2px';
        },
    },
    methods: {
        async launchGame() {
            this.$store.commit('launchGame', {});
        }
    }
});
</script>

<template>
    <nav>
        <el-button :disabled="northstarIsRunning"
                   type="primary" size="large" @click="launchGame"
                   class="fc_launch__button" :style="buttonRadiusStyle">
            {{ playButtonLabel }}
        </el-button>
        <el-select v-if="showReleaseSwitch" :disabled="northstarIsRunning"
                   v-model="currentCanal" placeholder="Select">
            <el-option-group
                v-for="group in selectOptions"
                :key="group.label"
                :label="group.label"
            >
                <el-option
                    v-for="item in group.options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                />
            </el-option-group>
        </el-select>
    </nav>
</template>

<style scoped>
button {
    text-transform: uppercase;
    padding: 30px;
    font-size: 15px;
    margin-right: 0;
}

.fc_launch__button:focus {
    background-color: var(--el-color-primary);
    border-color: var(--el-color-primary);
}

/* Release canal selector */
.el-select {
    width: 0;
    margin-right: 50px;
    border-left: 1px solid rgb(176, 205, 255);
}

.el-select:deep(.el-input__wrapper) {
    padding: 0 9px 0 0;
    background-color: var(--el-color-primary);
    border: none;
    border-radius: 0 2px 2px 0;
    height: 62px;
    box-shadow: none !important;
    --el-disabled-bg-color: #a0cfff;
}

.el-select:deep(.el-icon) {
    color: white !important;
}
</style>