Skip to content

Commit

Permalink
Fixes: cache last folder added to start next in same (parent) folder,…
Browse files Browse the repository at this point in the history
… Nuke global shortcut for local

Fixes #1
  • Loading branch information
jtsage committed Oct 24, 2022
1 parent 6e1095f commit 0d71cdc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions modAssist_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// Main Program

const { app, BrowserWindow, ipcMain, globalShortcut, shell, dialog, Menu, Tray, net } = require('electron')
const { app, BrowserWindow, ipcMain, shell, dialog, Menu, Tray, net } = require('electron')

const { autoUpdater } = require('electron-updater')
const { ma_logger } = require('./lib/ma-logger.js')
Expand Down Expand Up @@ -115,6 +115,7 @@ let countTotal = 0
let countMods = 0
let modHubList = {}
let modHubVersion = {}
let lastFolderLoc = null


const ignoreList = [
Expand Down Expand Up @@ -197,6 +198,10 @@ function createSubWindow({noSelect = true, show = true, parent = null, title = n
if (input.control && input.key.toLowerCase() === 'a') {
event.preventDefault()
}
if ( input.alt && input.control && input.key.toLowerCase() === 'd' ) {
createDebugWindow()
event.preventDefault()
}
})
}
if ( !devDebug ) { thisWindow.removeMenu()}
Expand Down Expand Up @@ -249,6 +254,10 @@ function createMainWindow () {
windows.main.webContents.send('fromMain_selectAllOpen')
event.preventDefault()
}
if ( input.alt && input.control && input.key.toLowerCase() === 'd' ) {
createDebugWindow()
event.preventDefault()
}
})

windows.main.webContents.setWindowOpenHandler(({ url }) => {
Expand Down Expand Up @@ -467,7 +476,7 @@ ipcMain.on('toMain_realFileVerCP', (event, fileMap) => { fileOperation('copy',
/** Folder Window Operation */
ipcMain.on('toMain_addFolder', () => {
dialog.showOpenDialog(windows.main, {
properties : ['openDirectory'], defaultPath : userHome,
properties : ['openDirectory'], defaultPath : (lastFolderLoc !== null) ? lastFolderLoc : userHome,
}).then((result) => {
if ( !result.canceled ) {
let alreadyExists = false
Expand All @@ -476,6 +485,8 @@ ipcMain.on('toMain_addFolder', () => {
if ( path.relative(thisPath, result.filePaths[0]) === '' ) { alreadyExists = true }
})

lastFolderLoc = path.resolve(path.join(result.filePaths[0], '..'))

if ( ! alreadyExists ) {
modFolders.add(result.filePaths[0]); foldersDirty = true
mcStore.set('modFolders', Array.from(modFolders))
Expand Down Expand Up @@ -979,8 +990,6 @@ function loadModHubVer() {


app.whenReady().then(() => {
globalShortcut.register('Alt+CommandOrControl+D', () => { createDebugWindow() })

if ( mcStore.has('force_lang') && mcStore.has('lock_lang') ) {
// If language is locked, switch to it.
myTranslator.currentLocale = mcStore.get('force_lang')
Expand Down

0 comments on commit 0d71cdc

Please sign in to comment.