stuff
This commit is contained in:
parent
7eb4c0fa70
commit
9afbe458d1
|
@ -6022,6 +6022,7 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let NativeSubSelectExport = (BDFDB.ModuleUtils.find(m => m == InternalComponents.NativeSubComponents.Select, false) || {exports: {}}).exports;
|
||||||
InternalComponents.LibraryComponents.Select = reactInitialized && class BDFDB_Select extends LibraryModules.React.Component {
|
InternalComponents.LibraryComponents.Select = reactInitialized && class BDFDB_Select extends LibraryModules.React.Component {
|
||||||
handleChange(value) {
|
handleChange(value) {
|
||||||
this.props.value = value.value || value;
|
this.props.value = value.value || value;
|
||||||
|
@ -6029,11 +6030,14 @@ module.exports = (_ => {
|
||||||
BDFDB.ReactUtils.forceUpdate(this);
|
BDFDB.ReactUtils.forceUpdate(this);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
let lightTheme = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
|
||||||
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Flex, {
|
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Flex, {
|
||||||
className: BDFDB.disCN.selectwrapper,
|
className: BDFDB.disCN.selectwrapper,
|
||||||
direction: InternalComponents.LibraryComponents.Flex.Direction.HORIZONTAL,
|
direction: InternalComponents.LibraryComponents.Flex.Direction.HORIZONTAL,
|
||||||
align: InternalComponents.LibraryComponents.Flex.Align.CENTER,
|
align: InternalComponents.LibraryComponents.Flex.Align.CENTER,
|
||||||
children: BDFDB.ReactUtils.createElement(InternalComponents.NativeSubComponents.Select, Object.assign({}, this.props, {
|
children: BDFDB.ReactUtils.createElement(InternalComponents.NativeSubComponents.Select, Object.assign({}, this.props, {
|
||||||
|
lightThemeColorOverrides: NativeSubSelectExport[lightTheme ? "LIGHT_THEME_COLORS" : "DARK_THEME_COLORS"],
|
||||||
|
darkThemeColorOverrides: NativeSubSelectExport[lightTheme ? "LIGHT_THEME_COLORS" : "DARK_THEME_COLORS"],
|
||||||
onChange: this.handleChange.bind(this)
|
onChange: this.handleChange.bind(this)
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
|
@ -6942,15 +6946,16 @@ module.exports = (_ => {
|
||||||
InternalBDFDB.appendCustomControls = function (card) {
|
InternalBDFDB.appendCustomControls = function (card) {
|
||||||
let checkbox = card.querySelector(BDFDB.dotCN._reposwitch);
|
let checkbox = card.querySelector(BDFDB.dotCN._reposwitch);
|
||||||
if (!checkbox) return;
|
if (!checkbox) return;
|
||||||
let addon = BDFDB.ObjectUtils.get(BDFDB.ReactUtils.getInstance(card), "return.stateNode.props.addon");
|
let props = BDFDB.ObjectUtils.get(BDFDB.ReactUtils.getInstance(card), "return.stateNode.props");
|
||||||
if (addon && addon.plugin && (addon.plugin == libraryInstance || addon.plugin.name && addon.plugin.name && PluginStores.started[addon.plugin.name] && PluginStores.started[addon.plugin.name] == addon.plugin)) {
|
if (props && !props.hasCustomControls && props.addon && props.addon.plugin && (props.addon.plugin == libraryInstance || props.addon.plugin.name && props.addon.plugin.name && PluginStores.started[props.addon.plugin.name] && PluginStores.started[props.addon.plugin.name] == props.addon.plugin)) {
|
||||||
|
props.hasCustomControls = true;
|
||||||
let controls = [];
|
let controls = [];
|
||||||
if (addon.plugin.changeLog) controls.push(InternalBDFDB.createCustomControl(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
|
if (props.addon.plugin.changeLog) controls.push(InternalBDFDB.createCustomControl(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
|
||||||
text: BDFDB.LanguageUtils.LanguageStrings.CHANGE_LOG,
|
text: BDFDB.LanguageUtils.LanguageStrings.CHANGE_LOG,
|
||||||
children: BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SvgIcon, {
|
children: BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SvgIcon, {
|
||||||
className: BDFDB.disCN._repoicon,
|
className: BDFDB.disCN._repoicon,
|
||||||
name: InternalComponents.LibraryComponents.SvgIcon.Names.CHANGELOG,
|
name: InternalComponents.LibraryComponents.SvgIcon.Names.CHANGELOG,
|
||||||
onClick: _ => {BDFDB.PluginUtils.openChangeLog(addon.plugin);}
|
onClick: _ => {BDFDB.PluginUtils.openChangeLog(props.addon.plugin);}
|
||||||
})
|
})
|
||||||
})));
|
})));
|
||||||
for (let control of controls) checkbox.parentElement.insertBefore(control, checkbox.parentElement.firstElementChild);
|
for (let control of controls) checkbox.parentElement.insertBefore(control, checkbox.parentElement.firstElementChild);
|
||||||
|
@ -7517,6 +7522,7 @@ module.exports = (_ => {
|
||||||
|
|
||||||
load () {
|
load () {
|
||||||
libraryInstance = this;
|
libraryInstance = this;
|
||||||
|
Object.assign(this, config.info, BDFDB.ObjectUtils.exclude(config, "info"));
|
||||||
if (!BDFDB.BDUtils.isPluginEnabled(config.info.name)) BDFDB.BDUtils.enablePlugin(config.info.name);
|
if (!BDFDB.BDUtils.isPluginEnabled(config.info.name)) BDFDB.BDUtils.enablePlugin(config.info.name);
|
||||||
}
|
}
|
||||||
start() {}
|
start() {}
|
||||||
|
|
|
@ -927,19 +927,19 @@ img:not([src]), img[src=""], img[src="null"] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toast {
|
.toast {
|
||||||
|
background-color: var(--background-primary);
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: var(--elevation-medium);
|
||||||
|
color: var(--header-primary);
|
||||||
|
margin-top: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
opacity: 1;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
user-select: text;
|
||||||
|
pointer-events: auto;
|
||||||
animation: toast-up 300ms ease;
|
animation: toast-up 300ms ease;
|
||||||
transform: translateY(-10px);
|
transform: translateY(-10px);
|
||||||
background-color: #36393F;
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 5px;
|
|
||||||
box-shadow: 0 0 0 1px rgba(32,34,37,.6), 0 2px 10px 0 rgba(0,0,0,.2);
|
|
||||||
font-weight: 500;
|
|
||||||
color: #fff;
|
|
||||||
user-select: text;
|
|
||||||
font-size: 14px;
|
|
||||||
opacity: 1;
|
|
||||||
margin-top: 10px;
|
|
||||||
pointer-events: auto;
|
|
||||||
}
|
}
|
||||||
@keyframes toast-down {
|
@keyframes toast-down {
|
||||||
to {
|
to {
|
||||||
|
|
|
@ -50,7 +50,7 @@ module.exports = (_ => {
|
||||||
|
|
||||||
var currentDevice = defaultDevice, createdAudios = {}, repatchIncoming;
|
var currentDevice = defaultDevice, createdAudios = {}, repatchIncoming;
|
||||||
|
|
||||||
/* NEVER CHANGE THE SRC LINKS IN THE PLUGIN FILE, TO ADD NEW SONGS ADD THEM IN THE SETTINGS GUI IN THE PLUGINS PAGE */
|
/* NEVER CHANGE THE SRC LINKS IN THE PLUGIN FILE, TO ADD NEW SOUNDS ADD THEM IN THE SETTINGS GUI IN THE PLUGINS PAGE */
|
||||||
const types = {
|
const types = {
|
||||||
"message1": {implemented:true, name:"New Chatmessage", src:"/assets/dd920c06a01e5bb8b09678581e29d56f.mp3", mute:true, focus:null, include:true},
|
"message1": {implemented:true, name:"New Chatmessage", src:"/assets/dd920c06a01e5bb8b09678581e29d56f.mp3", mute:true, focus:null, include:true},
|
||||||
"dm": {implemented:true, name:"Direct Message", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute:true, focus:true, include:false},
|
"dm": {implemented:true, name:"Direct Message", src:"/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute:true, focus:true, include:false},
|
||||||
|
@ -91,7 +91,7 @@ module.exports = (_ => {
|
||||||
"overlayunlock": {implemented:false, name:"Overlay Unlocked", src:"/assets/ad322ffe0a88436296158a80d5d11baa.mp3", mute:true, focus:null, include:true}
|
"overlayunlock": {implemented:false, name:"Overlay Unlocked", src:"/assets/ad322ffe0a88436296158a80d5d11baa.mp3", mute:true, focus:null, include:true}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* NEVER CHANGE THE SRC LINKS IN THE PLUGIN FILE, TO ADD NEW SONGS ADD THEM IN THE SETTINGS GUI IN THE PLUGINS PAGE */
|
/* NEVER CHANGE THE SRC LINKS IN THE PLUGIN FILE, TO ADD NEW SOUNDS ADD THEM IN THE SETTINGS GUI IN THE PLUGINS PAGE */
|
||||||
const defaultAudios = {
|
const defaultAudios = {
|
||||||
"---": {
|
"---": {
|
||||||
"---": null
|
"---": null
|
||||||
|
@ -113,7 +113,7 @@ module.exports = (_ => {
|
||||||
const WebAudioSound = class WebAudioSound {
|
const WebAudioSound = class WebAudioSound {
|
||||||
constructor (type) {
|
constructor (type) {
|
||||||
this._name = type;
|
this._name = type;
|
||||||
this._src = choices[type].src;
|
this._src = audios[choices[type].category][choices[type].sound] || types[type].src;
|
||||||
this._volume = choices[type].volume;
|
this._volume = choices[type].volume;
|
||||||
}
|
}
|
||||||
loop () {
|
loop () {
|
||||||
|
@ -348,8 +348,7 @@ module.exports = (_ => {
|
||||||
searchable: true,
|
searchable: true,
|
||||||
onChange: category => {
|
onChange: category => {
|
||||||
choices[type].category = category.value;
|
choices[type].category = category.value;
|
||||||
choices[type].song = Object.keys(audios[category.value] || {})[0];
|
choices[type].sound = Object.keys(audios[category.value] || {})[0];
|
||||||
choices[type].src = audios[choices[type].category][choices[type].song] || types[type].src;
|
|
||||||
this.saveChoice(type, true);
|
this.saveChoice(type, true);
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||||
}
|
}
|
||||||
|
@ -361,14 +360,13 @@ module.exports = (_ => {
|
||||||
shrink: 0,
|
shrink: 0,
|
||||||
basis: "31%",
|
basis: "31%",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: "Song",
|
title: "Sound",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, {
|
||||||
value: choices[type].song,
|
value: choices[type].sound,
|
||||||
options: Object.keys(audios[choices[type].category] || {}).map(name => ({value:name, label:name})),
|
options: Object.keys(audios[choices[type].category] || {}).map(name => ({value:name, label:name})),
|
||||||
searchable: true,
|
searchable: true,
|
||||||
onChange: song => {
|
onChange: sound => {
|
||||||
choices[type].song = song.value;
|
choices[type].sound = sound.value;
|
||||||
choices[type].src = audios[choices[type].category][choices[type].song] || types[type].src;
|
|
||||||
this.saveChoice(type, true);
|
this.saveChoice(type, true);
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||||
}
|
}
|
||||||
|
@ -403,9 +401,9 @@ module.exports = (_ => {
|
||||||
};
|
};
|
||||||
|
|
||||||
let successSavedAudio = data => {
|
let successSavedAudio = data => {
|
||||||
BDFDB.NotificationUtils.toast(`Song ${data.song} was added to category ${data.category}.`, {type:"success"});
|
BDFDB.NotificationUtils.toast(`Sound ${data.sound} was added to category ${data.category}.`, {type:"success"});
|
||||||
if (!audios[data.category]) audios[data.category] = {};
|
if (!audios[data.category]) audios[data.category] = {};
|
||||||
audios[data.category][data.song] = data.source;
|
audios[data.category][data.sound] = data.source;
|
||||||
BDFDB.DataUtils.save(audios, this, "audios");
|
BDFDB.DataUtils.save(audios, this, "audios");
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||||
|
|
||||||
|
@ -414,7 +412,7 @@ module.exports = (_ => {
|
||||||
let settingsPanel, settingsItems = [];
|
let settingsPanel, settingsItems = [];
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Add new Song",
|
title: "Add new Sound",
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: [
|
children: [
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||||
|
@ -424,7 +422,7 @@ module.exports = (_ => {
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: "Categoryname",
|
title: "Categoryname",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
className: "input-newsong input-category",
|
className: "input-newsound input-category",
|
||||||
value: "",
|
value: "",
|
||||||
placeholder: "Categoryname"
|
placeholder: "Categoryname"
|
||||||
})
|
})
|
||||||
|
@ -432,11 +430,11 @@ module.exports = (_ => {
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: "Songname",
|
title: "Soundname",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
className: "input-newsong input-song",
|
className: "input-newsound input-sound",
|
||||||
value: "",
|
value: "",
|
||||||
placeholder: "Songname"
|
placeholder: "Soundname"
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -450,7 +448,7 @@ module.exports = (_ => {
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: "Source",
|
title: "Source",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
className: "input-newsong input-source",
|
className: "input-newsound input-source",
|
||||||
type: "file",
|
type: "file",
|
||||||
filter: ["audio", "video"],
|
filter: ["audio", "video"],
|
||||||
useFilePath: true,
|
useFilePath: true,
|
||||||
|
@ -462,20 +460,20 @@ module.exports = (_ => {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||||
style: {marginBottom: 1},
|
style: {marginBottom: 1},
|
||||||
onClick: _ => {
|
onClick: _ => {
|
||||||
for (let input of settingsPanel.querySelectorAll(".input-newsong " + BDFDB.dotCN.input)) if (!input.value || input.value.length == 0 || input.value.trim().length == 0) return BDFDB.NotificationUtils.toast("Fill out all fields to add a new song.", {type:"danger"});
|
for (let input of settingsPanel.querySelectorAll(".input-newsound " + BDFDB.dotCN.input)) if (!input.value || input.value.length == 0 || input.value.trim().length == 0) return BDFDB.NotificationUtils.toast("Fill out all fields to add a new sound.", {type:"danger"});
|
||||||
let category = settingsPanel.querySelector(".input-category " + BDFDB.dotCN.input).value.trim();
|
let category = settingsPanel.querySelector(".input-category " + BDFDB.dotCN.input).value.trim();
|
||||||
let song = settingsPanel.querySelector(".input-song " + BDFDB.dotCN.input).value.trim();
|
let sound = settingsPanel.querySelector(".input-sound " + BDFDB.dotCN.input).value.trim();
|
||||||
let source = settingsPanel.querySelector(".input-source " + BDFDB.dotCN.input).value.trim();
|
let source = settingsPanel.querySelector(".input-source " + BDFDB.dotCN.input).value.trim();
|
||||||
if (source.indexOf("http") == 0) BDFDB.LibraryRequires.request(source, (error, response, result) => {
|
if (source.indexOf("http") == 0) BDFDB.LibraryRequires.request(source, (error, response, result) => {
|
||||||
if (response) {
|
if (response) {
|
||||||
let type = response.headers["content-type"];
|
let type = response.headers["content-type"];
|
||||||
if (type && (type.indexOf("octet-stream") > -1 || type.indexOf("audio") > -1 || type.indexOf("video") > -1)) return successSavedAudio({category, song, source});
|
if (type && (type.indexOf("octet-stream") > -1 || type.indexOf("audio") > -1 || type.indexOf("video") > -1)) return successSavedAudio({category, sound, source});
|
||||||
}
|
}
|
||||||
BDFDB.NotificationUtils.toast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"});
|
BDFDB.NotificationUtils.toast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"});
|
||||||
});
|
});
|
||||||
else BDFDB.LibraryRequires.fs.readFile(source, (error, response) => {
|
else BDFDB.LibraryRequires.fs.readFile(source, (error, response) => {
|
||||||
if (error) BDFDB.NotificationUtils.toast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
|
if (error) BDFDB.NotificationUtils.toast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
|
||||||
else return successSavedAudio({category, song, source:`data:audio/mpeg;base64,${response.toString("base64")}`});
|
else return successSavedAudio({category, sound, source:`data:audio/mpeg;base64,${response.toString("base64")}`});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
children: BDFDB.LanguageUtils.LanguageStrings.SAVE
|
children: BDFDB.LanguageUtils.LanguageStrings.SAVE
|
||||||
|
@ -495,11 +493,11 @@ module.exports = (_ => {
|
||||||
children: Object.keys(BDFDB.ObjectUtils.filter(types, typedata => !typedata.implemented)).map(type => createSoundCard(type)).flat(10).filter(n => n)
|
children: Object.keys(BDFDB.ObjectUtils.filter(types, typedata => !typedata.implemented)).map(type => createSoundCard(type)).flat(10).filter(n => n)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let removeableCategories = [{value:removeAllKey, label:BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL}].concat(Object.keys(audios).filter(category => !(defaultAudios[category] && !Object.keys(audios[category] || {}).filter(song => defaultAudios[category][song] === undefined).length)).map(name => ({value:name, label:name})));
|
let removeableCategories = [{value:removeAllKey, label:BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL}].concat(Object.keys(audios).filter(category => !(defaultAudios[category] && !Object.keys(audios[category] || {}).filter(sound => defaultAudios[category][sound] === undefined).length)).map(name => ({value:name, label:name})));
|
||||||
let removeableSongs = {};
|
let removeableSounds = {};
|
||||||
for (let category of removeableCategories) removeableSongs[category.value] = [{value:removeAllKey, label:BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL}].concat(Object.keys(audios[category.value] || {}).filter(song => !(defaultAudios[category.value] && defaultAudios[category.value][song] !== undefined)).map(name => ({value:name, label:name})));
|
for (let category of removeableCategories) removeableSounds[category.value] = [{value:removeAllKey, label:BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL}].concat(Object.keys(audios[category.value] || {}).filter(sound => !(defaultAudios[category.value] && defaultAudios[category.value][sound] !== undefined)).map(name => ({value:name, label:name})));
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Remove Songs",
|
title: "Remove Sounds",
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||||
className: BDFDB.disCN.margintop4,
|
className: BDFDB.disCN.margintop4,
|
||||||
|
@ -517,11 +515,11 @@ module.exports = (_ => {
|
||||||
options: removeableCategories,
|
options: removeableCategories,
|
||||||
searchable: true,
|
searchable: true,
|
||||||
onChange: (category, instance) => {
|
onChange: (category, instance) => {
|
||||||
let songSelectIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true}), {key:"REMOVE_SONG"});
|
let soundSelectIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true}), {key:"REMOVE_SOUND"});
|
||||||
if (songSelectIns && removeableSongs[category.value]) {
|
if (soundSelectIns && removeableSounds[category.value]) {
|
||||||
songSelectIns.props.options = removeableSongs[category.value];
|
soundSelectIns.props.options = removeableSounds[category.value];
|
||||||
songSelectIns.props.value = removeAllKey;
|
soundSelectIns.props.value = removeAllKey;
|
||||||
BDFDB.ReactUtils.forceUpdate(songSelectIns);
|
BDFDB.ReactUtils.forceUpdate(soundSelectIns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -532,11 +530,11 @@ module.exports = (_ => {
|
||||||
shrink: 0,
|
shrink: 0,
|
||||||
basis: "35%",
|
basis: "35%",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: "Song",
|
title: "Sound",
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, {
|
||||||
key: "REMOVE_SONG",
|
key: "REMOVE_SOUND",
|
||||||
value: removeAllKey,
|
value: removeAllKey,
|
||||||
options: removeableSongs[removeAllKey],
|
options: removeableSounds[removeAllKey],
|
||||||
searchable: true
|
searchable: true
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -551,20 +549,20 @@ module.exports = (_ => {
|
||||||
onClick: (event, instance) => {
|
onClick: (event, instance) => {
|
||||||
let wrapperIns = BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true});
|
let wrapperIns = BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true});
|
||||||
let categorySelectIns = BDFDB.ReactUtils.findOwner(wrapperIns, {key:"REMOVE_CATEGORY"});
|
let categorySelectIns = BDFDB.ReactUtils.findOwner(wrapperIns, {key:"REMOVE_CATEGORY"});
|
||||||
let songSelectIns = BDFDB.ReactUtils.findOwner(wrapperIns, {key:"REMOVE_SONG"});
|
let soundSelectIns = BDFDB.ReactUtils.findOwner(wrapperIns, {key:"REMOVE_SOUND"});
|
||||||
if (categorySelectIns && songSelectIns) {
|
if (categorySelectIns && soundSelectIns) {
|
||||||
let songAmount = 0;
|
let soundAmount = 0;
|
||||||
let catAll = categorySelectIns.props.value == removeAllKey;
|
let catAll = categorySelectIns.props.value == removeAllKey;
|
||||||
let songAll = songSelectIns.props.value == removeAllKey;
|
let soundAll = soundSelectIns.props.value == removeAllKey;
|
||||||
if (catAll) songAmount = BDFDB.ArrayUtils.sum(Object.keys(audios).map(category => Object.keys(audios[category] || {}).filter(song => !(defaultAudios[category] && defaultAudios[category][song] !== undefined)).length));
|
if (catAll) soundAmount = BDFDB.ArrayUtils.sum(Object.keys(audios).map(category => Object.keys(audios[category] || {}).filter(sound => !(defaultAudios[category] && defaultAudios[category][sound] !== undefined)).length));
|
||||||
else if (songAll) songAmount = Object.keys(audios[categorySelectIns.props.value] || {}).filter(song => !(defaultAudios[categorySelectIns.props.value] && defaultAudios[categorySelectIns.props.value][song] !== undefined)).length;
|
else if (soundAll) soundAmount = Object.keys(audios[categorySelectIns.props.value] || {}).filter(sound => !(defaultAudios[categorySelectIns.props.value] && defaultAudios[categorySelectIns.props.value][sound] !== undefined)).length;
|
||||||
else if (audios[categorySelectIns.props.value][songSelectIns.props.value]) songAmount = 1;
|
else if (audios[categorySelectIns.props.value][soundSelectIns.props.value]) soundAmount = 1;
|
||||||
|
|
||||||
if (songAmount) BDFDB.ModalUtils.confirm(this, `Are you sure you want to delete ${songAmount} added song${songAmount == 1 ? "" : "s"}?`, _ => {
|
if (soundAmount) BDFDB.ModalUtils.confirm(this, `Are you sure you want to delete ${soundAmount} added sound${soundAmount == 1 ? "" : "s"}?`, _ => {
|
||||||
if (catAll) BDFDB.DataUtils.remove(this, "audios");
|
if (catAll) BDFDB.DataUtils.remove(this, "audios");
|
||||||
else if (songAll) BDFDB.DataUtils.remove(this, "audios", categorySelectIns.props.value);
|
else if (soundAll) BDFDB.DataUtils.remove(this, "audios", categorySelectIns.props.value);
|
||||||
else {
|
else {
|
||||||
delete audios[categorySelectIns.props.value][songSelectIns.props.value];
|
delete audios[categorySelectIns.props.value][soundSelectIns.props.value];
|
||||||
if (BDFDB.ObjectUtils.isEmpty(audios[categorySelectIns.props.value])) delete audios[categorySelectIns.props.value];
|
if (BDFDB.ObjectUtils.isEmpty(audios[categorySelectIns.props.value])) delete audios[categorySelectIns.props.value];
|
||||||
BDFDB.DataUtils.save(audios, this, "audios");
|
BDFDB.DataUtils.save(audios, this, "audios");
|
||||||
}
|
}
|
||||||
|
@ -572,7 +570,7 @@ module.exports = (_ => {
|
||||||
this.loadChoices();
|
this.loadChoices();
|
||||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||||
});
|
});
|
||||||
else BDFDB.NotificationUtils.toast("No songs to delete.", {type:"danger"});
|
else BDFDB.NotificationUtils.toast("No sounds to delete.", {type:"danger"});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
children: BDFDB.LanguageUtils.LanguageStrings.DELETE
|
children: BDFDB.LanguageUtils.LanguageStrings.DELETE
|
||||||
|
@ -628,16 +626,19 @@ module.exports = (_ => {
|
||||||
loadChoices () {
|
loadChoices () {
|
||||||
let loadedChoices = BDFDB.DataUtils.load(this, "choices");
|
let loadedChoices = BDFDB.DataUtils.load(this, "choices");
|
||||||
for (let type in types) {
|
for (let type in types) {
|
||||||
let choice = loadedChoices[type] || {}, songFound = false;
|
let choice = loadedChoices[type] || {}, soundFound = false;
|
||||||
for (let category in audios) if (choice.category == category) for (let song in audios[category]) if (choice.song == song) {
|
// REMOVE 06.10.2020
|
||||||
songFound = true;
|
choice.sound = choice.song || choice.sound;
|
||||||
|
delete choice.song;
|
||||||
|
delete choice.src;
|
||||||
|
for (let category in audios) if (choice.category == category) for (let sound in audios[category]) if (choice.sound == sound) {
|
||||||
|
soundFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!songFound) choice = {
|
if (!soundFound) choice = {
|
||||||
category: "---",
|
category: "---",
|
||||||
song: "---",
|
sound: "---",
|
||||||
volume: 100,
|
volume: 100,
|
||||||
src: types[type].src,
|
|
||||||
mute: types[type].mute,
|
mute: types[type].mute,
|
||||||
focus: types[type].focus
|
focus: types[type].focus
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
--blurple: rgb(var(--vaccentcolor));
|
--blurple: rgb(var(--vaccentcolor));
|
||||||
}
|
}
|
||||||
.theme-dark, .theme-light {
|
.theme-dark, .theme-light {
|
||||||
|
--logo-primary: rgb(var(--vaccentcolor));
|
||||||
--text-link: rgb(var(--vlinkcolor));
|
--text-link: rgb(var(--vlinkcolor));
|
||||||
--focus-primary: rgb(var(--vlinkcolor));
|
--focus-primary: rgb(var(--vlinkcolor));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue