From dfb28b1d6937a976a5e36d0227fca27e89b415d1 Mon Sep 17 00:00:00 2001 From: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> Date: Sun, 29 May 2022 16:36:59 -0400 Subject: [PATCH] Feat: SponsorBlock improvements (#1849) * Add setting for each SB category * Update SB Settings Component * Show other SB categories in seek bar * Use camelCase for SponsorBlock values Co-authored-by: PikachuEXE * change "Don't Skip" to "Do Nothing" in locale * improve styling of sponsorblock settings * add filler category, don't repeat colors * Fix JS format issue caused during code conflict resolving * make sponsor block markers transparent * change opacity to 0.6 Co-authored-by: PikachuEXE --- .../ft-sponsor-block-category.js | 142 ++++++++++++++++++ .../ft-sponsor-block-category.sass | 6 + .../ft-sponsor-block-category.vue | 23 +++ .../ft-video-player/ft-video-player.js | 96 ++++++++---- .../sponsor-block-settings.js | 18 ++- .../sponsor-block-settings.vue | 7 + .../theme-settings/theme-settings.js | 59 ++------ src/renderer/store/modules/settings.js | 32 ++++ src/renderer/store/modules/utils.js | 56 +++---- static/locales/en-US.yaml | 21 ++- 10 files changed, 350 insertions(+), 110 deletions(-) create mode 100644 src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.js create mode 100644 src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.sass create mode 100644 src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.vue diff --git a/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.js b/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.js new file mode 100644 index 00000000..f74378ff --- /dev/null +++ b/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.js @@ -0,0 +1,142 @@ +import Vue from 'vue' +import { mapActions } from 'vuex' +import FtSelect from '../ft-select/ft-select.vue' + +export default Vue.extend({ + name: 'FtSponsorBlockCategory', + components: { + 'ft-select': FtSelect + }, + props: { + categoryName: { + type: String, + required: true + } + }, + data: function () { + return { + categoryColor: '', + skipOption: '', + skipValues: [ + 'autoSkip', + // 'promptToSkip', + 'showInSeekBar', + 'doNothing' + ] + } + }, + computed: { + colorValues: function () { + return this.$store.getters.getColorNames + }, + + colorNames: function () { + return this.colorValues.map(colorVal => { + // add spaces before capital letters + const colorName = colorVal.replace(/([A-Z])/g, ' $1').trim() + return this.$t(`Settings.Theme Settings.Main Color Theme.${colorName}`) + }) + }, + + sponsorBlockValues: function() { + let sponsorVal = '' + switch (this.categoryName.toLowerCase()) { + case 'sponsor': + sponsorVal = this.$store.getters.getSponsorBlockSponsor + break + case 'self-promotion': + sponsorVal = this.$store.getters.getSponsorBlockSelfPromo + break + case 'interaction': + sponsorVal = this.$store.getters.getSponsorBlockInteraction + break + case 'intro': + sponsorVal = this.$store.getters.getSponsorBlockIntro + break + case 'outro': + sponsorVal = this.$store.getters.getSponsorBlockOutro + break + case 'recap': + sponsorVal = this.$store.getters.getSponsorBlockRecap + break + case 'music offtopic': + sponsorVal = this.$store.getters.getSponsorBlockMusicOffTopic + break + case 'filler': + sponsorVal = this.$store.getters.getSponsorBlockFiller + break + } + return sponsorVal + }, + + skipNames: function() { + return [ + this.$t('Settings.SponsorBlock Settings.Skip Options.Auto Skip'), + // this.$t('Settings.SponsorBlock Settings.Skip Options.Prompt To Skip'), + this.$t('Settings.SponsorBlock Settings.Skip Options.Show In Seek Bar'), + this.$t('Settings.SponsorBlock Settings.Skip Options.Do Nothing') + ] + } + }, + + methods: { + updateColor: function (color) { + const payload = { + color: color, + skip: this.sponsorBlockValues.skip + } + this.updateSponsorCategory(payload) + }, + + updateSkipOption: function (skipOption) { + const payload = { + color: this.sponsorBlockValues.color, + skip: skipOption + } + + this.updateSponsorCategory(payload) + }, + + updateSponsorCategory: function (payload) { + switch (this.categoryName.toLowerCase()) { + case 'sponsor': + this.updateSponsorBlockSponsor(payload) + break + case 'self-promotion': + this.updateSponsorBlockSelfPromo(payload) + break + case 'interaction': + this.updateSponsorBlockInteraction(payload) + break + case 'intro': + this.updateSponsorBlockIntro(payload) + break + case 'outro': + this.updateSponsorBlockOutro(payload) + break + case 'recap': + this.updateSponsorBlockRecap(payload) + break + case 'music offtopic': + this.updateSponsorBlockMusicOffTopic(payload) + break + case 'filler': + this.updateSponsorBlockFiller(payload) + break + } + }, + + ...mapActions([ + 'showToast', + 'openExternalLink', + 'updateSponsorBlockSponsor', + 'updateSponsorBlockSelfPromo', + 'updateSponsorBlockInteraction', + 'updateSponsorBlockIntro', + 'updateSponsorBlockOutro', + 'updateSponsorBlockRecap', + 'updateSponsorBlockMusicOffTopic', + 'updateSponsorBlockFiller' + ]) + } +}) diff --git a/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.sass b/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.sass new file mode 100644 index 00000000..ead66f12 --- /dev/null +++ b/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.sass @@ -0,0 +1,6 @@ +@use "../../sass-partials/settings" +.sponsorBlockCategory + margin-top: 30px + padding: 0 10px + .sponsorTitle + font-size: x-large diff --git a/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.vue b/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.vue new file mode 100644 index 00000000..80d63d1e --- /dev/null +++ b/src/renderer/components/ft-sponsor-block-category/ft-sponsor-block-category.vue @@ -0,0 +1,23 @@ + +