Set image quality

This commit is contained in:
redphx
2025-01-04 12:33:47 +07:00
parent 3fe6d97133
commit 097164b92e
7 changed files with 87 additions and 0 deletions

View File

@@ -86,6 +86,7 @@ export const enum PrefKey {
UI_SKIP_SPLASH_VIDEO = 'ui.splashVideo.skip',
UI_HIDE_SYSTEM_MENU_ICON = 'ui.systemMenu.hideHandle',
UI_REDUCE_ANIMATIONS = 'ui.reduceAnimations',
UI_IMAGE_QUALITY = 'ui.imageQuality',
VIDEO_PLAYER_TYPE = 'video.player.type',
VIDEO_POWER_PREFERENCE = 'video.player.powerPreference',
@@ -172,6 +173,7 @@ export type PrefTypeMap = {
[PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME]: boolean,
[PrefKey.UI_HIDE_SECTIONS]: UiSection[],
[PrefKey.UI_HIDE_SYSTEM_MENU_ICON]: boolean,
[PrefKey.UI_IMAGE_QUALITY]: number,
[PrefKey.UI_LAYOUT]: UiLayout,
[PrefKey.UI_REDUCE_ANIMATIONS]: boolean,
[PrefKey.UI_SCROLLBAR_HIDE]: boolean,

View File

@@ -1081,6 +1081,28 @@ ${subsVar} = subs;
return str;
},
*/
// 27.0.6-hotfix.1, 78831.js
setImageQuality(str: string) {
let index = str.indexOf('const{size:{width:');
index > -1 && (index = PatcherUtils.indexOf(str, '=new URLSearchParams', index, 500));
if (index < 0) {
return false;
}
const paramVar = PatcherUtils.getVariableNameBefore(str, index);
if (!paramVar) {
return false;
}
// Find "return" keyword
index = PatcherUtils.indexOf(str, 'return', index, 200);
const newCode = `${paramVar}.set('q', ${getPref(PrefKey.UI_IMAGE_QUALITY)});`;
str = PatcherUtils.insertAt(str, index, newCode);
return str;
},
};
let PATCH_ORDERS = PatcherUtils.filterPatches([
@@ -1094,6 +1116,8 @@ let PATCH_ORDERS = PatcherUtils.filterPatches([
'gameCardCustomIcons',
// 'gameCardPassTitle',
getPref(PrefKey.UI_IMAGE_QUALITY) < 90 && 'setImageQuality',
'modifyPreloadedState',
'optimizeGameSlugGenerator',

View File

@@ -274,6 +274,7 @@ export class SettingsDialog extends NavigationDialog {
label: t('ui'),
items: [
PrefKey.UI_LAYOUT,
PrefKey.UI_IMAGE_QUALITY,
PrefKey.UI_GAME_CARD_SHOW_WAIT_TIME,
PrefKey.UI_CONTROLLER_SHOW_STATUS,
PrefKey.UI_SIMPLIFY_STREAM_MENU,

View File

@@ -192,6 +192,23 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
label: t('hide-system-menu-icon'),
default: false,
},
[PrefKey.UI_IMAGE_QUALITY]: {
label: t('image-quality'),
default: 90,
min: 10,
max: 90,
params: {
steps: 10,
exactTicks: 20,
customTextValue(value, min, max) {
if (value === 90) {
return t('default');
}
return value + '%';
},
},
},
[PrefKey.STREAM_COMBINE_SOURCES]: {
requiredVariants: 'full',

View File

@@ -151,6 +151,7 @@ const Texts = {
"how-to-fix": "How to fix",
"how-to-improve-app-performance": "How to improve app's performance",
"ignore": "Ignore",
"image-quality": "Image quality",
"import": "Import",
"in-game-controller-customization": "In-game controller customization",
"in-game-controller-shortcuts": "In-game controller shortcuts",