Added drag/drop functionality to the add mods button.

You can now drag one or more files onto the add mods button in order to add them to the mods directory. Only jar, litemod, and zip files will be moved.
Changed eslint to use a single configuration file, with overrides for the UI scripts.
Now using fs-extra, replace usages of rimraf and mkdirp with fs-extra functions.
This commit is contained in:
Daniel Scalzi
2018-12-01 08:20:42 -05:00
parent d9c9b32446
commit d779eacf61
11 changed files with 170 additions and 143 deletions

View File

@@ -643,6 +643,25 @@ function bindDropinModFileSystemButton(){
DropinModUtil.validateModsDir(CACHE_SETTINGS_MODS_DIR)
shell.openItem(CACHE_SETTINGS_MODS_DIR)
}
fsBtn.ondragenter = e => {
e.dataTransfer.dropEffect = 'move'
fsBtn.setAttribute('drag', '')
e.preventDefault()
}
fsBtn.ondragover = e => {
e.preventDefault()
}
fsBtn.ondragleave = e => {
fsBtn.removeAttribute('drag')
}
fsBtn.ondrop = e => {
fsBtn.removeAttribute('drag')
e.preventDefault()
DropinModUtil.addDropinMods(e.dataTransfer.files, CACHE_SETTINGS_MODS_DIR)
reloadDropinMods()
}
}
/**
@@ -676,14 +695,18 @@ function saveDropinModConfiguration(){
document.addEventListener('keydown', (e) => {
if(getCurrentView() === VIEWS.settings && selectedSettingsTab === 'settingsTabMods'){
if(e.key === 'F5'){
resolveDropinModsForUI()
bindDropinModsRemoveButton()
bindDropinModFileSystemButton()
bindModsToggleSwitch()
reloadDropinMods()
}
}
})
function reloadDropinMods(){
resolveDropinModsForUI()
bindDropinModsRemoveButton()
bindDropinModFileSystemButton()
bindModsToggleSwitch()
}
// Server status bar functions.
/**