Skip to content

Commit bab8539

Browse files
authored
Merge pull request #1857 from ebkr/remember-last-platform-selected
Platform selection radio now persists last selected option
2 parents 56aae9f + 51e3cb4 commit bab8539

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/pages/GameSelectionScreen.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,15 @@ function selectGame(game: Game) {
240240
selectedGame.value = game;
241241
isSettingDefaultPlatform.value = false;
242242
if (game.storePlatformMetadata.length > 1) {
243-
selectedPlatform.value = null;
243+
ManagerSettings.getSingleton(game)
244+
.then(settings => settings.getLastSelectedPlatform())
245+
.then(platform => {
246+
if (platform) {
247+
selectedPlatform.value = Platform[platform]
248+
} else {
249+
selectedPlatform.value = null;
250+
}
251+
});
244252
showPlatformModal.value = true;
245253
} else {
246254
selectedPlatform.value = game.storePlatformMetadata[0].storePlatform;
@@ -297,6 +305,7 @@ async function proceed() {
297305
298306
const settings = await ManagerSettings.getSingleton(selectedGame.value);
299307
await settings.setLastSelectedGame(selectedGame.value);
308+
await settings.setLastSelectedPlatform(selectedPlatform.value);
300309
await GameManager.activate(selectedGame.value, selectedPlatform.value);
301310
await store.dispatch("setActiveGame", selectedGame.value);
302311
@@ -312,7 +321,7 @@ async function proceedDefault() {
312321
await settings.setDefaultGame(selectedGame.value);
313322
await settings.setDefaultStorePlatform(selectedPlatform.value);
314323
315-
proceed();
324+
return proceed();
316325
}
317326
318327
function toggleFavourite(game: Game) {

src/r2mm/manager/ManagerSettings.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ export default class ManagerSettings {
172172
return undefined;
173173
}
174174

175+
public getLastSelectedPlatform(): Platform | null {
176+
if (ManagerSettings.CONTEXT.gameSpecific.lastSelectedPlatform) {
177+
return EnumResolver.from<Platform>(Platform, ManagerSettings.CONTEXT.gameSpecific.lastSelectedPlatform);
178+
}
179+
return null;
180+
}
181+
175182
public async setInstalledDisablePosition(disablePosition: string) {
176183
ManagerSettings.CONTEXT.gameSpecific.installedDisablePosition = EnumResolver.from<SortLocalDisabledMods>(SortLocalDisabledMods, disablePosition);
177184
await this.save();
@@ -210,4 +217,9 @@ export default class ManagerSettings {
210217
ManagerSettings.CONTEXT.gameSpecific.launchType = launchType;
211218
await this.save();
212219
}
220+
221+
public async setLastSelectedPlatform(platform: Platform) {
222+
ManagerSettings.CONTEXT.gameSpecific.lastSelectedPlatform = platform;
223+
await this.save();
224+
}
213225
}

src/r2mm/manager/SettingsDexieStore.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export default class SettingsDexieStore extends Dexie {
132132
launchParameters: "",
133133
linkedFiles: [],
134134
launchType: LaunchType.AUTO,
135+
lastSelectedPlatform: null,
135136
}
136137
}
137138
}
@@ -214,6 +215,7 @@ export interface ManagerSettingsInterfaceGame_V2 {
214215
installedSortDirection: string;
215216
installedDisablePosition: string;
216217
launchType: string;
218+
lastSelectedPlatform: string | null;
217219
}
218220

219221
/**

0 commit comments

Comments
 (0)