From 7a5a4bddf83e91f8ef880c980c81381e672d5a6e Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 16 Dec 2020 00:19:02 +0100 Subject: [PATCH] support passing debug data between content script and UI --- src/csui/PlayerUiComponent.vue | 16 ++++++++++++++-- src/ext/lib/uwui/PlayerUI.js | 26 +++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/csui/PlayerUiComponent.vue b/src/csui/PlayerUiComponent.vue index c9af662..9d4aac3 100644 --- a/src/csui/PlayerUiComponent.vue +++ b/src/csui/PlayerUiComponent.vue @@ -14,12 +14,18 @@ export default { }, data() { return { - uiVisible: true + uiVisible: true, + debugData: { + resizer: {}, + player: {}, + } }; }, computed: { ...mapState([ - 'showUi' + 'showUi', + 'resizerDebugData', + 'playerDebugData' ]), }, watch: { @@ -27,6 +33,12 @@ export default { if (visible !== undefined) { this.uiVisible = visible; } + }, + resizerDebugData(newData) { + this.debugData.resizer = newData; + }, + playerDebugData(newData) { + this.debugData.player = newData; } }, created() { diff --git a/src/ext/lib/uwui/PlayerUI.js b/src/ext/lib/uwui/PlayerUI.js index 312b04e..a3a2b89 100644 --- a/src/ext/lib/uwui/PlayerUI.js +++ b/src/ext/lib/uwui/PlayerUI.js @@ -40,7 +40,9 @@ class PlayerUi extends UI { plugins: [ VuexWebExtensions({ persistentStates: [ - 'showUi' + 'showUi', + 'resizerDebugData', + 'playerDebugData', ], }), ], @@ -53,7 +55,13 @@ class PlayerUi extends UI { }, 'uw-set-ui-visible'(state, payload) { state['showUi'] = payload; - } + }, + 'uw-set-player-debug-data'(state, payload) { + state['playerDebugData'] = payload; + }, + 'uw-set-resizer-debug-data'(state, payload) { + state['resizerDebugData'] = payload; + }, }, actions: { 'uw-set-ui-visible'({commit}, payload) { @@ -62,7 +70,13 @@ class PlayerUi extends UI { }, 'uw-toggle-ui'({commit}) { commit('uw-toggle-ui'); - } + }, + 'uw-set-player-debug-data'({commit}, payload) { + commit('uw-set-player-debug-data ', payload); + }, + 'uw-set-resizer-debug-data'({commit}, payload) { + commit('uw-set-resizer-debug-data ', payload); + }, } }; } @@ -90,6 +104,12 @@ class PlayerUi extends UI { super.replace(this.getUiConfig(playerElement)); } //#endregion + + //#region debug methods + updateDebugInfo(component, data) { + this.vuexStore?.dispatch(`uw-set-${component}-debug-data`, data); + } + //#endregion } if (process.env.CHANNEL !== 'stable'){