15
15
</div >
16
16
<button class =" modal-close is-large" aria-label =" close" @click =" downloadingMod = false;" ></button >
17
17
</div >
18
- <ModalCard :is-active =" isOpen" :can-close =" true" v-if =" thunderstoreMod !== null" @close-modal =" closeModal()" >
19
- <template v-slot :header >
20
- <h2 class =' modal-title' v-if =" thunderstoreMod !== null" >
21
- Select a version of {{thunderstoreMod.getName()}} to download
22
- </h2 >
23
- </template >
24
- <template v-slot :body >
25
- <p >It's recommended to select the latest version of all mods.</p >
26
- <p >Using outdated versions may cause problems.</p >
27
- <br />
28
- <div class =" columns is-vcentered" >
29
- <template v-if =" currentVersion !== null " >
30
- <div class =" column is-narrow" >
31
- <select class =" select" disabled =" true" >
32
- <option selected >
33
- {{currentVersion}}
34
- </option >
35
- </select >
36
- </div >
37
- <div class =" column is-narrow" >
38
- <span class =" margin-right margin-right--half-width" ><span class =" margin-right margin-right--half-width" /> <i class =' fas fa-long-arrow-alt-right' ></i ></span >
39
- </div >
40
- </template >
41
- <div class =" column is-narrow" >
42
- <select class =' select' v-model =' selectedVersion' >
43
- <option v-for =' (value, index) in versionNumbers' :key =' index' v-bind:value =' value' >
44
- {{value}}
45
- </option >
46
- </select >
47
- </div >
48
- <div class =" column is-narrow" >
49
- <span class =" tag is-dark" v-if =' selectedVersion === null' >
50
- You need to select a version
51
- </span >
52
- <span class =" tag is-success" v-else-if =' recommendedVersion === selectedVersion' >
53
- {{selectedVersion}} is the recommended version
54
- </span >
55
- <span class =" tag is-success" v-else-if =' versionNumbers[0] === selectedVersion' >
56
- {{selectedVersion}} is the latest version
57
- </span >
58
- <span class =" tag is-danger" v-else-if =' versionNumbers[0] !== selectedVersion' >
59
- {{selectedVersion}} is an outdated version
60
- </span >
61
- </div >
62
- </div >
63
- </template >
64
- <template v-slot :footer >
65
- <button class =" button is-info" @click =" downloadThunderstoreMod()" >Download with dependencies</button >
66
- </template >
67
- </ModalCard >
18
+ <DownloadModVersionSelectModal @download-mod =" downloadHandler" />
68
19
<ModalCard :is-active =" isOpen" :can-close =" true" v-if =" thunderstoreMod === null" @close-modal =" closeModal()" >
69
20
<template v-slot :header >
70
21
<h2 class =' modal-title' >Update all installed mods</h2 >
90
41
91
42
<script lang="ts">
92
43
93
- import { Component , Vue , Watch } from ' vue-property-decorator' ;
44
+ import { mixins } from " vue-class-component" ;
45
+ import { Component } from ' vue-property-decorator' ;
94
46
import ThunderstoreMod from ' ../../model/ThunderstoreMod' ;
95
47
import ManifestV2 from ' ../../model/ManifestV2' ;
96
48
import ThunderstoreVersion from ' ../../model/ThunderstoreVersion' ;
@@ -102,12 +54,11 @@ import ProfileInstallerProvider from '../../providers/ror2/installing/ProfileIns
102
54
import ProfileModList from ' ../../r2mm/mods/ProfileModList' ;
103
55
import Profile from ' ../../model/Profile' ;
104
56
import { Progress } from ' ../all' ;
105
- import Game from ' ../../model/game/Game' ;
106
57
import ConflictManagementProvider from ' ../../providers/generic/installing/ConflictManagementProvider' ;
107
- import { MOD_LOADER_VARIANTS } from ' ../../r2mm/installing/profile_installers/ModLoaderVariantRecord' ;
108
58
import ModalCard from ' ../ModalCard.vue' ;
109
- import * as PackageDb from ' ../../r2mm/manager/PackageDexieStore' ;
110
59
import { installModsToProfile } from ' ../../utils/ProfileUtils' ;
60
+ import DownloadMixin from " ../mixins/DownloadMixin.vue" ;
61
+ import DownloadModVersionSelectModal from " ../../components/views/DownloadModVersionSelectModal.vue" ;
111
62
112
63
interface DownloadProgress {
113
64
assignId: number ;
@@ -121,29 +72,18 @@ let assignId = 0;
121
72
122
73
@Component ({
123
74
components: {
75
+ DownloadModVersionSelectModal ,
124
76
ModalCard ,
125
77
Progress
126
78
}
127
79
})
128
- export default class DownloadModModal extends Vue {
80
+ export default class DownloadModModal extends mixins ( DownloadMixin ) {
129
81
130
- versionNumbers: string [] = [];
131
- recommendedVersion: string | null = null ;
132
82
downloadObject: DownloadProgress | null = null ;
133
83
downloadingMod: boolean = false ;
134
- selectedVersion: string | null = null ;
135
- currentVersion: string | null = null ;
136
84
137
85
static allVersions: [number , DownloadProgress ][] = [];
138
86
139
- get activeGame(): Game {
140
- return this .$store .state .activeGame ;
141
- }
142
-
143
- get profile(): Profile {
144
- return this .$store .getters [' profile/activeProfile' ];
145
- }
146
-
147
87
get ignoreCache(): boolean {
148
88
const settings = this .$store .getters [' settings' ];
149
89
return settings .getContext ().global .ignoreCache ;
@@ -212,78 +152,6 @@ let assignId = 0;
212
152
});
213
153
}
214
154
215
- get thunderstoreMod(): ThunderstoreMod | null {
216
- return this .$store .state .modals .downloadModModalMod ;
217
- }
218
-
219
- get isOpen(): boolean {
220
- return this .$store .state .modals .isDownloadModModalOpen ;
221
- }
222
-
223
- @Watch (' $store.state.modals.downloadModModalMod' )
224
- async getModVersions() {
225
- this .currentVersion = null ;
226
- if (this .thunderstoreMod !== null ) {
227
- this .selectedVersion = this .thunderstoreMod .getLatestVersion ();
228
- this .recommendedVersion = null ;
229
-
230
- this .versionNumbers = await PackageDb .getPackageVersionNumbers (
231
- this .activeGame .internalFolderName ,
232
- this .thunderstoreMod .getFullName ()
233
- );
234
-
235
- const foundRecommendedVersion = MOD_LOADER_VARIANTS [this .activeGame .internalFolderName ]
236
- .find (value => value .packageName === this .thunderstoreMod ! .getFullName ());
237
-
238
- if (foundRecommendedVersion && foundRecommendedVersion .recommendedVersion ) {
239
- this .recommendedVersion = foundRecommendedVersion .recommendedVersion .toString ();
240
-
241
- // Auto-select recommended version if it's found.
242
- const recommendedVersion = this .versionNumbers .find (
243
- (ver ) => ver === foundRecommendedVersion .recommendedVersion ! .toString ()
244
- );
245
- if (recommendedVersion ) {
246
- this .selectedVersion = recommendedVersion ;
247
- }
248
- }
249
-
250
- const modListResult = await ProfileModList .getModList (this .profile .asImmutableProfile ());
251
- if (! (modListResult instanceof R2Error )) {
252
- const manifestMod = modListResult .find ((local : ManifestV2 ) => local .getName () === this .thunderstoreMod ! .getFullName ());
253
- if (manifestMod !== undefined ) {
254
- this .currentVersion = manifestMod .getVersionNumber ().toString ();
255
- }
256
- }
257
- }
258
- }
259
-
260
- closeModal() {
261
- this .$store .commit (" closeDownloadModModal" );
262
- }
263
-
264
- async downloadThunderstoreMod() {
265
- const refSelectedThunderstoreMod: ThunderstoreMod | null = this .thunderstoreMod ;
266
- const refSelectedVersion: string | null = this .selectedVersion ;
267
- if (refSelectedThunderstoreMod === null || refSelectedVersion === null ) {
268
- // Shouldn't happen, but shouldn't throw an error.
269
- return ;
270
- }
271
-
272
- let version: ThunderstoreVersion ;
273
-
274
- try {
275
- version = await PackageDb .getVersionAsThunderstoreVersion (
276
- this .activeGame .internalFolderName ,
277
- refSelectedThunderstoreMod .getFullName (),
278
- refSelectedVersion
279
- );
280
- } catch {
281
- return ;
282
- }
283
-
284
- this .downloadHandler (refSelectedThunderstoreMod , version );
285
- }
286
-
287
155
async downloadLatest() {
288
156
this .closeModal ();
289
157
const modsWithUpdates: ThunderstoreCombo [] = await this .$store .dispatch (' profile/getCombosWithUpdates' );
0 commit comments