Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin: Additional keybind on song selection #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions song-select/additional-keybind.taikoweb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
export default class Plugin extends Patch {
name = "Additional Shortcuts"
version = "22.05.27"
description = `Add additional shortcuts.
Ctrl+P => Open Plugin Setting
Ctrl+S => Open Settings
Ctrl+R => Select Random Song
Ctrl+C => Select Custom Song
Ctrl+M => Mute Song (You can also mute song by pressing Q key)
`



author = "mirusu400"


strings = {

}

load() {
this.addEdits(
new EditFunction(SongSelect.prototype, "init").load(str => {
return plugins.strReplace(str, `search: ["f"]`, `
search: ["f"],
plugin: ["p"],
setting: ["s"],
random: ["r"],
custom: ["c"],
mute: ["m"]
`)
}),

new EditFunction(SongSelect.prototype, "keyPress").load(str => {
return plugins.insertBefore(str,
`
if(event && event.keyCode && event.keyCode === 80 && ctrl){ // Ctrl+P => Open Plugin Setting
this.toPlugins()
if(event){
event.preventDefault()
}
}
if (event && event.keyCode && event.keyCode === 83 && ctrl) { // Ctrl+S => Settings
this.toSettings()
if(event){
event.preventDefault()
}
}
if (event && event.keyCode && event.keyCode === 82 && ctrl) { // Ctrl+R => Random
do{
var i = Math.floor(Math.random() * this.songs.length)
}while(!this.songs[i].courses)
this.setSelectedSong(i)
this.lastRandom = true
this.playBgm(false)
this.toSelectDifficulty(false, playVoice=false)
pageEvents.send("song-select-random")
if(event){
event.preventDefault()
}
}
if (event && event.keyCode && event.keyCode === 67 && ctrl) { // Ctrl+C => Custom song
this.toCustomSongs()
if(event){
event.preventDefault()
}
}
if (event && event.keyCode && event.keyCode === 77 && ctrl) { // Ctrl+M => Mute song
this.endPreview(true)
this.playBgm(false)
if(event){
event.preventDefault()
}
}
`,
`if(event && event.keyCode && event.keyCode === 70 && ctrl){`)
})
)
}

settings() {
return []
}
}