Added the ability for characters to override the client theme
This commit is contained in:
		
							parent
							
								
									0d3d111f8c
								
							
						
					
					
						commit
						b463e00294
					
				@ -219,6 +219,17 @@
 | 
				
			|||||||
                    Show high-quality portraits
 | 
					                    Show high-quality portraits
 | 
				
			||||||
                </label>
 | 
					                </label>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <div class="form-group">
 | 
				
			||||||
 | 
					                <label class="control-label" for="risingCharacterTheme">
 | 
				
			||||||
 | 
					                    Select character theme
 | 
				
			||||||
 | 
					                    <select id="risingCharacterTheme" class="form-control" v-model="risingCharacterTheme" style="flex:1;margin-right:10px">
 | 
				
			||||||
 | 
					                        <option value=undefined>Client theme</option>
 | 
				
			||||||
 | 
					                        <option disabled>---</option>
 | 
				
			||||||
 | 
					                        <option v-for="theme in risingAvailableThemes" :value="theme">{{theme}}</option>
 | 
				
			||||||
 | 
					                    </select>
 | 
				
			||||||
 | 
					                </label>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <div v-show="selectedTab === '3'">
 | 
					        <div v-show="selectedTab === '3'">
 | 
				
			||||||
@ -334,6 +345,8 @@
 | 
				
			|||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script lang="ts">
 | 
					<script lang="ts">
 | 
				
			||||||
 | 
					    import * as fs from 'fs';
 | 
				
			||||||
 | 
					    import * as path from 'path';
 | 
				
			||||||
    import {Component} from '@f-list/vue-ts';
 | 
					    import {Component} from '@f-list/vue-ts';
 | 
				
			||||||
    import CustomDialog from '../components/custom_dialog';
 | 
					    import CustomDialog from '../components/custom_dialog';
 | 
				
			||||||
    import Modal from '../components/Modal.vue';
 | 
					    import Modal from '../components/Modal.vue';
 | 
				
			||||||
@ -394,6 +407,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        risingFilter!: SmartFilterSettings = {} as any;
 | 
					        risingFilter!: SmartFilterSettings = {} as any;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        risingAvailableThemes!: ReadonlyArray<string> = [];
 | 
				
			||||||
 | 
					        risingCharacterTheme!: string | undefined;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        smartFilterTypes = smartFilterTypesOrigin;
 | 
					        smartFilterTypes = smartFilterTypesOrigin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        async load(): Promise<void> {
 | 
					        async load(): Promise<void> {
 | 
				
			||||||
@ -438,6 +454,9 @@
 | 
				
			|||||||
            this.risingShowHighQualityPortraits = settings.risingShowHighQualityPortraits;
 | 
					            this.risingShowHighQualityPortraits = settings.risingShowHighQualityPortraits;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            this.risingFilter = settings.risingFilter;
 | 
					            this.risingFilter = settings.risingFilter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            this.risingAvailableThemes = fs.readdirSync(path.join(__dirname, 'themes')).filter((x) => x.substr(-4) === '.css').map((x) => x.slice(0, -4));
 | 
				
			||||||
 | 
					            this.risingCharacterTheme = settings.risingCharacterTheme;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        async doImport(): Promise<void> {
 | 
					        async doImport(): Promise<void> {
 | 
				
			||||||
@ -506,7 +525,9 @@
 | 
				
			|||||||
                  ...this.risingFilter,
 | 
					                  ...this.risingFilter,
 | 
				
			||||||
                  minAge: (minAge !== null && maxAge !== null) ? Math.min(minAge, maxAge) : minAge,
 | 
					                  minAge: (minAge !== null && maxAge !== null) ? Math.min(minAge, maxAge) : minAge,
 | 
				
			||||||
                  maxAge: (minAge !== null && maxAge !== null) ? Math.max(minAge, maxAge) : maxAge
 | 
					                  maxAge: (minAge !== null && maxAge !== null) ? Math.max(minAge, maxAge) : maxAge
 | 
				
			||||||
                }
 | 
					                },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                risingCharacterTheme: this.risingCharacterTheme != "undefined" ? this.risingCharacterTheme : undefined
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            console.log('SETTINGS', minAge, maxAge, core.state.settings);
 | 
					            console.log('SETTINGS', minAge, maxAge, core.state.settings);
 | 
				
			||||||
 | 
				
			|||||||
@ -104,6 +104,8 @@ export class Settings implements ISettings {
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        exceptionNames: []
 | 
					        exceptionNames: []
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    risingCharacterTheme = undefined;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -240,6 +240,8 @@ export namespace Settings {
 | 
				
			|||||||
        readonly risingShowHighQualityPortraits: boolean;
 | 
					        readonly risingShowHighQualityPortraits: boolean;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        readonly risingFilter: SmartFilterSettings;
 | 
					        readonly risingFilter: SmartFilterSettings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        readonly risingCharacterTheme: string | undefined;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -543,7 +543,7 @@
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return {
 | 
					            return {
 | 
				
			||||||
              [`theme-${this.settings.theme}`]: true,
 | 
					              [`theme-${core.state.settings.risingCharacterTheme || this.settings.theme}`]: true,
 | 
				
			||||||
              colorblindMode: core.state.settings.risingColorblindMode,
 | 
					              colorblindMode: core.state.settings.risingColorblindMode,
 | 
				
			||||||
              disableWindowsHighContrast: core.state.generalSettings?.risingDisableWindowsHighContrast || false
 | 
					              disableWindowsHighContrast: core.state.generalSettings?.risingDisableWindowsHighContrast || false
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
@ -593,9 +593,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        get styling(): string {
 | 
					        get styling(): string {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                return `<style id="themeStyle">${fs.readFileSync(path.join(__dirname, `themes/${this.settings.theme}.css`), 'utf8').toString()}</style>`;
 | 
					                return `<style id="themeStyle">${fs.readFileSync(path.join(__dirname, `themes/${((this.character != undefined && core.state.settings.risingCharacterTheme) || this.settings.theme)}.css`), 'utf8').toString()}</style>`;
 | 
				
			||||||
            } catch(e) {
 | 
					            } catch(e) {
 | 
				
			||||||
                if((<Error & {code: string}>e).code === 'ENOENT' && this.settings.theme !== 'default') {
 | 
					              if((<Error & {code: string}>e).code === 'ENOENT' && this.settings.theme !== 'default') {
 | 
				
			||||||
                    this.settings.theme = 'default';
 | 
					                    this.settings.theme = 'default';
 | 
				
			||||||
                    return this.styling;
 | 
					                    return this.styling;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user