2020-12-15 00:26:19 +01:00
|
|
|
import UI from './UI';
|
|
|
|
import VuexWebExtensions from 'vuex-webextensions';
|
|
|
|
import PlayerUiComponent from '../../../csui/PlayerUiComponent.vue';
|
|
|
|
|
|
|
|
if (process.env.CHANNEL !== 'stable'){
|
|
|
|
console.info("Loading: PlayerUi");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class that handles in-player UI
|
|
|
|
*/
|
|
|
|
class PlayerUi extends UI {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates new in-player UI for ultrawidify
|
|
|
|
* @param {*} playerElement PlayerUI will be created as a child of this element
|
|
|
|
* @param {*} settings Extension settings (instanceof Settings)
|
|
|
|
*/
|
|
|
|
constructor (
|
|
|
|
playerElement,
|
|
|
|
settings
|
|
|
|
) {
|
|
|
|
super(
|
|
|
|
'ultrawidifyUi',
|
|
|
|
PlayerUi.getStoreConfig(),
|
|
|
|
PlayerUi.getUiConfig(playerElement),
|
|
|
|
PlayerUi.getCommsConfig()
|
|
|
|
);
|
|
|
|
|
|
|
|
this.settings = settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//#region constructor helpers
|
|
|
|
// we will move some things out of the constructor in order to keep things clean
|
|
|
|
static getStoreConfig() {
|
|
|
|
// NOTE: these are sample values and can be deleted. Currently, they're commented out
|
|
|
|
// so we won't have to look up the documentation in order to get them working
|
|
|
|
return {
|
|
|
|
plugins: [
|
|
|
|
VuexWebExtensions({
|
|
|
|
persistentStates: [
|
2020-12-16 00:19:02 +01:00
|
|
|
'showUi',
|
|
|
|
'resizerDebugData',
|
|
|
|
'playerDebugData',
|
2020-12-15 00:26:19 +01:00
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
state: {
|
|
|
|
showUi: true,
|
|
|
|
},
|
|
|
|
mutations: {
|
|
|
|
'uw-toggle-ui'(state) {
|
|
|
|
state['showUi'] = !state['showUi'];
|
|
|
|
},
|
|
|
|
'uw-set-ui-visible'(state, payload) {
|
|
|
|
state['showUi'] = payload;
|
2020-12-16 00:19:02 +01:00
|
|
|
},
|
|
|
|
'uw-set-player-debug-data'(state, payload) {
|
|
|
|
state['playerDebugData'] = payload;
|
|
|
|
},
|
|
|
|
'uw-set-resizer-debug-data'(state, payload) {
|
|
|
|
state['resizerDebugData'] = payload;
|
|
|
|
},
|
2020-12-15 00:26:19 +01:00
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
'uw-set-ui-visible'({commit}, payload) {
|
|
|
|
console.log('action!', commit, payload);
|
|
|
|
commit('uw-set-ui-visible', payload);
|
|
|
|
},
|
|
|
|
'uw-toggle-ui'({commit}) {
|
|
|
|
commit('uw-toggle-ui');
|
2020-12-16 00:19:02 +01:00
|
|
|
},
|
|
|
|
'uw-set-player-debug-data'({commit}, payload) {
|
2020-12-17 01:49:15 +01:00
|
|
|
commit('uw-set-player-debug-data', payload);
|
2020-12-16 00:19:02 +01:00
|
|
|
},
|
|
|
|
'uw-set-resizer-debug-data'({commit}, payload) {
|
2020-12-16 01:35:39 +01:00
|
|
|
commit('uw-set-resizer-debug-data', payload);
|
2020-12-16 00:19:02 +01:00
|
|
|
},
|
2020-12-15 00:26:19 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static getUiConfig(playerElement) {
|
|
|
|
return {
|
|
|
|
parentElement: playerElement,
|
|
|
|
component: PlayerUiComponent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static getCommsConfig() {
|
|
|
|
// NOTE: these are sample values and can be deleted. Currently, they're commented out
|
|
|
|
// so we won't have to look up the documentation in order to get them working
|
|
|
|
return {
|
|
|
|
handlers: {
|
|
|
|
// 'show-notification': [(message) => this.showNotification(message)],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region lifecycle
|
|
|
|
replace(playerElement) {
|
|
|
|
super.replace(this.getUiConfig(playerElement));
|
|
|
|
}
|
|
|
|
//#endregion
|
2020-12-16 00:19:02 +01:00
|
|
|
|
|
|
|
//#region debug methods
|
|
|
|
updateDebugInfo(component, data) {
|
|
|
|
this.vuexStore?.dispatch(`uw-set-${component}-debug-data`, data);
|
|
|
|
}
|
|
|
|
//#endregion
|
2020-12-15 00:26:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (process.env.CHANNEL !== 'stable'){
|
|
|
|
console.info("PlayerUi loaded");
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PlayerUi;
|