Skip to content

Commit

Permalink
Suggest values from gameSettings.xml in the collection notes (when no…
Browse files Browse the repository at this point in the history
…t already set)
  • Loading branch information
jtsage committed Nov 12, 2022
1 parent 2bb4508 commit c976d07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 9 additions & 2 deletions modAssist_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ let countMods = 0
let modHubList = {}
let modHubVersion = {}
let lastFolderLoc = null
let lastGameSettings = {}


const ignoreList = [
Expand Down Expand Up @@ -459,14 +460,14 @@ function createSavegameWindow(collection) {
function createNotesWindow(collection) {
if ( windows.notes ) {
windows.notes.focus()
windows.notes.webContents.send('fromMain_collectionName', collection, modList[collection].name, modNote.store)
windows.notes.webContents.send('fromMain_collectionName', collection, modList[collection].name, modNote.store, lastGameSettings)
return
}

windows.notes = createSubWindow({ parent : 'main', preload : 'notesWindow', maximize : mcStore.get('detail_window_max') })

windows.notes.webContents.on('did-finish-load', async (event) => {
event.sender.send('fromMain_collectionName', collection, modList[collection].name, modNote.store)
event.sender.send('fromMain_collectionName', collection, modList[collection].name, modNote.store, lastGameSettings)
if ( devDebug ) { windows.notes.webContents.openDevTools() }
})

Expand Down Expand Up @@ -993,6 +994,12 @@ function parseSettings({disable = null, newFolder = null, userName = null, serve
gameSettingsXML = XMLParser.parse(XMLString)
overrideActive = gameSettingsXML.gameSettings.modsDirectoryOverride['@_active']
overrideFolder = gameSettingsXML.gameSettings.modsDirectoryOverride['@_directory']
lastGameSettings = {
username : gameSettingsXML.gameSettings.onlinePresenceName || '',
password : gameSettingsXML.gameSettings.joinGame['@_password'] || '',
server : gameSettingsXML.gameSettings.joinGame['@_serverName'] || '',
}

} catch (e) {
log.log.danger(`Could not read game settings ${e}`, 'game-settings')
}
Expand Down
9 changes: 7 additions & 2 deletions renderer/renderJS/notes_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ window.l10n.receive('fromMain_getText_return', (data) => {
})
window.l10n.receive('fromMain_l10n_refresh', () => { processL10N() })

window.mods.receive('fromMain_collectionName', (collection, collectionName, allNotes) => {
window.mods.receive('fromMain_collectionName', (collection, collectionName, allNotes, lastGameSettings) => {
thisCollection = collection
fsgUtil.byId('collection_name').innerHTML = collectionName

fsgUtil.query('input').forEach((element) => {
let thisValue = ''

let thisPlaceholder = lastGameSettings[element.id.replace('notes_', '')]
if ( typeof allNotes[collection] !== 'undefined' ) {
thisValue = allNotes[collection][element.id]
thisValue = allNotes[collection][element.id]
thisPlaceholder = ( typeof thisValue !== 'undefined' ) ? '' : thisPlaceholder
}

element.placeholder = ( typeof thisPlaceholder !== 'undefined' ) ? thisPlaceholder : ''
element.value = ( typeof thisValue !== 'undefined' ) ? thisValue : ''
})

Expand Down

0 comments on commit c976d07

Please sign in to comment.