Add Toggle to use theme BG in options menu

This commit is contained in:
maximuslotro 2023-08-15 00:15:22 -05:00
parent a9b1fa0130
commit a31bc46c39
No known key found for this signature in database
GPG Key ID: B1E2F56B635C0902
20 changed files with 41 additions and 4 deletions

View File

@ -89,6 +89,9 @@ This does not include commonly used components (buttons, divider lines, commit a
| `#menuOptionsContainerBG` | Container for Background option |
| `#menuOptionsLabelBG` | Label for background option |
| `#menuOptionsDirBG` | Container for background url/local path option |
| `#menuOptionsContainerUseThemeBG` | Container for forcing theme background option |
| `#menuOptionsLabelUseThemeBG` | Label for forcing theme background option |
| `#menuOptionsUseThemeBG` | Toggle forcing theme background button container |
| `#menuOptionsContainerLang` | Container for language change option |
| `#menuOptionsLabelLang` | Label for language change option |
| `#menuOptionsSelectLang` | Container for language change select menu |

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "随游戏自动启动 Grasscutter",
"language": "选择语言",
"background": "设置自定义背景(链接或文件)",
"use_theme_background": "使用所选主题提供的背景",
"theme": "设置主题",
"patch_rsa": "自动修改RSA",
"use_proxy": "使用内置代理",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "伴隨遊戲一起啟動Grasscutter",
"language": "語言",
"background": "選擇自定義背景(網址或檔案)",
"use_theme_background": "使用所選主題提供的背景",
"theme": "選擇主題",
"patch_rsa": "自動修補RSA",
"use_proxy": "使用內建代理伺服器",

View File

@ -24,6 +24,7 @@
"grasscutter_with_game": "Grasscutter automatisch mit dem Spiel starten",
"language": "Sprache auswählen",
"background": "Benutzerdefinierten Hintergrund festlegen (link oder bild)",
"use_theme_background": "Verwenden Sie den vom ausgewählten Thema bereitgestellten Hintergrund",
"theme": "Theme auswählen",
"patch_rsa": "RSA automatisch patchen",
"use_proxy": "Gebruik interne proxy",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "Automatically launch Grasscutter with game",
"language": "Select Language",
"background": "Set Custom Background (link or image file)",
"use_theme_background": "Use the background supplied by selected theme",
"theme": "Set Theme",
"patch_rsa": "Automatically Patch RSA",
"use_proxy": "Use Internal Proxy",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "Iniciar automáticamente Grasscutter con el juego",
"language": "Seleccionar Idioma",
"background": "Establecer Fondo Personalizado (link o archivo de imagen)",
"use_theme_background": "Usar fondo proporcionado por el tema seleccionado",
"patch_rsa": "Parchear RSA automáticamente",
"theme": "Establecer Tema",
"use_proxy": "Usar proxy interno",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "Lancer Grasscutter automatiquement avec le jeu",
"language": "Choisir la langue",
"background": "Définir un arriere plan personnalisé (lien ou fichier image)",
"use_theme_background": "Utiliser l'arrière-plan fourni par le thème sélectionné",
"theme": "Définir un theme",
"patch_rsa": "Patcher automatiquement les clés RSA",
"use_proxy": "Utiliser le proxy interne",

View File

@ -24,6 +24,7 @@
"grasscutter_with_game": "Otomatis Menjalankan Grasscutter Dengan Game",
"language": "Pilih Bahasa",
"background": "Atur Kustom Latar Belakang (link atau gambar file)",
"use_theme_background": "Gunakan latar belakang yang disediakan oleh tema yang dipilih",
"theme": "Atur Tema",
"patch_rsa": "Automatically Patch RSA",
"use_proxy": "Gunakan Proxy Internal",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "Avvia automaticamente Grasscutter con il gioco",
"language": "Imposta lingua",
"background": "Imposta sfondo personalizzato (link o immagine)",
"use_theme_background": "Usa lo sfondo fornito dal tema selezionato",
"theme": "Imposta tema",
"patch_rsa": "Patch RSA automaticamente",
"use_proxy": "Usa Proxy Interno",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "게임에서 자동으로 그래스커터 실행",
"language": "언어 선택",
"background": "사용자 지정 배경 설정(링크 또는 이미지 파일)",
"use_theme_background": "선택한 테마에서 제공하는 배경 사용",
"theme": "테마 설정",
"patch_rsa": "RSA 패치 자동 적용",
"use_proxy": "내부 프록시 사용",

View File

@ -23,6 +23,7 @@
"grasscutter_with_game": "Automātiski palaidiet Grasscutter ar spēli",
"language": "Izvēlēties valodu",
"background": "Iestatīt pielāgotu fonu (saite vai attēla fails)",
"use_theme_background": "Izmantojiet atlasītā motīva nodrošināto fonu",
"theme": "Iestatīt tēmu",
"patch_rsa": "Automātiski ielāpot RSA",
"use_proxy": "Izmantot iekšējo starpniekserveri",

View File

@ -24,6 +24,7 @@
"grasscutter_with_game": "Start Automatisch Grasscutter Met Spel",
"language": "Selecteer Taal",
"background": "Aangepaste Achtergrond Instellen (link of afbeeldingsbestand)",
"use_theme_background": "Gebruik de achtergrond geleverd door het geselecteerde thema",
"theme": "Thema instellen",
"patch_rsa": "RSA Automatisch Bijwerken",
"use_proxy": "Gebruik Interne Proxy",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "Automatycznie uruchom Grasscutter z grą",
"language": "Wybierz Język",
"background": "Ustaw własne tło (link lub plik graficzny)",
"use_theme_background": "Użyj tła dostarczonego przez wybrany motyw",
"theme": "Ustaw motyw",
"patch_rsa": "Automatycznie patchuj RSA",
"use_proxy": "Używaj wewnętrznego Proxy",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "Iniciar automaticamente o Grasscutter com o Jogo",
"language": "Selecionar Idioma",
"background": "Definir Fundo Customizado (link ou arquivo de imagem)",
"use_theme_background": "Use o plano de fundo fornecido pelo tema selecionado",
"theme": "Definir Tema",
"patch_rsa": "Automaticamente Corrigir RSA",
"use_proxy": "Usar Proxy Interno",

View File

@ -24,6 +24,7 @@
"grasscutter_with_game": "Автоматически запускать Grasscutter вместе с игрой",
"language": "Установить язык",
"background": "Установить свой фон (ссылка или файл)",
"use_theme_background": "Использовать фон из выбранной темы",
"theme": "Установить тему",
"patch_rsa": "Автоматическое исправление RSA",
"use_proxy": "Использовать встроенный Прокси",

View File

@ -25,6 +25,7 @@
"grasscutter_with_game": "Tự động chạy Grasscutter cùng với game",
"language": "Ngôn ngữ",
"background": "Hình nền tùy chỉnh (liên kết hoặc tập tin hình ảnh)",
"use_theme_background": "Sử dụng nền được cung cấp bởi chủ đề đã chọn",
"theme": "Giao diện",
"patch_rsa": "Tự động vá RSA",
"use_proxy": "Sử dụng proxy nội bộ",

View File

@ -16,6 +16,7 @@ pub struct Configuration {
pub last_port: Option<String>,
pub language: Option<String>,
pub custom_background: Option<String>,
pub use_theme_background: Option<bool>,
pub cert_generated: Option<bool>,
pub theme: Option<String>,
pub https_enabled: Option<bool>,

View File

@ -33,6 +33,7 @@ interface IState {
bg_url_or_path: string
themes: string[]
theme: string
use_theme_background: boolean
encryption: boolean
patch_rsa: boolean
use_internal_proxy: boolean
@ -64,6 +65,7 @@ export default class Options extends React.Component<IProps, IState> {
bg_url_or_path: '',
themes: ['default'],
theme: '',
use_theme_background: false,
encryption: false,
patch_rsa: false,
use_internal_proxy: false,
@ -119,6 +121,7 @@ export default class Options extends React.Component<IProps, IState> {
bg_url_or_path: config.custom_background || '',
themes: (await getThemeList()).map((t) => t.name),
theme: config.theme || 'default',
use_theme_background: config.use_theme_background || false,
encryption: encEnabled || false,
patch_rsa: config.patch_rsa || false,
use_internal_proxy: config.use_internal_proxy || false,
@ -538,6 +541,19 @@ export default class Options extends React.Component<IProps, IState> {
</div>
</div>
<div className="OptionSection" id="menuOptionsContainerUseThemeBG">
<div className="OptionLabel" id="menuOptionsLabelUseThemeBG">
<Tr text="options.use_theme_background" />
</div>
<div className="OptionValue" id="menuOptionsUseThemeBG">
<Checkbox
onChange={() => this.toggleOption('use_theme_background')}
checked={this.state?.use_theme_background}
id="useThemeBG"
/>
</div>
</div>
<Divider />
<div className="OptionSection" id="menuOptionsContainerJavaPath">

View File

@ -16,6 +16,7 @@ let defaultConfig: Configuration
last_port: '443',
language: 'en',
custom_background: '',
use_theme_background: false,
cert_generated: false,
theme: 'default',
https_enabled: false,
@ -45,6 +46,7 @@ export interface Configuration {
last_port: string
language: string
custom_background: string
use_theme_background: boolean
cert_generated: boolean
theme: string
https_enabled: boolean

View File

@ -115,8 +115,8 @@ export async function loadTheme(theme: ThemeList, document: Document) {
// Set custom background
if (theme.customBackgroundURL) {
// If the custom bg is already set don't overwrite
if (config.custom_background === '') {
// If the custom bg is already set don't overwrite unless user wants to force the new background
if (config.custom_background === '' || config.use_theme_background) {
config.custom_background = theme.customBackgroundURL
}
}
@ -133,8 +133,8 @@ export async function loadTheme(theme: ThemeList, document: Document) {
})
// Set the background
// If the custom bg is already set don't overwrite
if (config.custom_background === '') {
// If the custom bg is already set don't overwrite unless user wants to force the new background
if (config.custom_background === '' || config.use_theme_background) {
config.custom_background = bgPath + imageName
}
}