feat: prompt for restart when changing renderer

This commit is contained in:
Acaki
2025-08-19 04:04:18 +08:00
parent 62bd695138
commit 4e44136f51
3 changed files with 135 additions and 1 deletions
@@ -3837,6 +3837,98 @@
}
}
},
"Quit Now" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "立即退出"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "立即退出"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "立即退出"
}
}
}
},
"Rendering mode change requires app restart" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "更改渲染模式需要重启应用以确保干净启动。您是否要立即退出应用?"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "更改渲染模式需要重新啟動應用程式以確保乾淨啟動。您是否要立即退出應用程式?"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "更改渲染模式需要重新啟動應用程式以確保乾淨啟動。您是否要立即退出應用程式?"
}
}
}
},
"Restart Required" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "需要重启"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "需要重新啟動"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "需要重新啟動"
}
}
}
},
"Later" : {
"extractionState" : "manual",
"localizations" : {
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "稍后"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "稍後"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "稍後"
}
}
}
},
"Read Widget Instruction" : {
"extractionState" : "manual",
"localizations" : {
@@ -1636,6 +1636,48 @@ BOOL isCustomResolution(int resolutionSelected) {
}
- (void)renderingBackendChanged:(UISegmentedControl *)sender {
// Get the current settings to compare with the new selection
DataManager* dataMan = [[DataManager alloc] init];
TemporarySettings* currentSettings = [dataMan getSettings];
NSInteger previousBackend = [currentSettings.renderingBackend integerValue];
// Check if the rendering backend has actually changed
if (previousBackend != sender.selectedSegmentIndex) {
// Show alert to prompt user to restart the app
NSString *message = [LocalizationHelper localizedStringForKey:@"Rendering mode change requires app restart"];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:[LocalizationHelper localizedStringForKey:@"Restart Required"]
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *quitAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Quit Now"]
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * _Nonnull action) {
DataManager* directDataMan = [[DataManager alloc] init];
Settings* directSettings = [directDataMan retrieveSettings];
directSettings.renderingBackend = [NSNumber numberWithInteger:sender.selectedSegmentIndex];
[directDataMan saveData];
[self saveSettings];
exit(0);
}];
UIAlertAction *laterAction = [UIAlertAction actionWithTitle:[LocalizationHelper localizedStringForKey:@"Later"]
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * _Nonnull action) {
// Save settings immediately to persist the renderer change
[self saveSettings];
}];
[alertController addAction:laterAction];
[alertController addAction:quitAction];
[self presentViewController:alertController animated:YES completion:nil];
}
// Disable PiP toggle when Metal renderer is selected
if (sender.selectedSegmentIndex == RENDER_METAL) {
// Performance mode (Metal renderer) selected - disable PiP
@@ -36,7 +36,7 @@ import UIKit
"widgetLayoutTool":SwiftLocalizationHelper.localizedString(forKey: "[ On-screen widget tool ]"),
"bringUpSoftKeyboard":SwiftLocalizationHelper.localizedString(forKey: "[ Bring up soft keyboard ]"),
"enterPip":SwiftLocalizationHelper.localizedString(forKey: "[ Enter picture-in-picture mode ]"),
"toggleStatsOverlay":SwiftLocalizationHelper.localizedString(forKey: "[ Toggle stats overlay & graphs ]")
"toggleStatsOverlay":SwiftLocalizationHelper.localizedString(forKey: "[ Toggle stats overlay & graphs ]"),
"disconnectAndQuitApp":SwiftLocalizationHelper.localizedString(forKey: "[ Disconnect & quit app ]")
]