diff --git a/lib/single-mod-checker.js b/lib/single-mod-checker.js index 550a4a3e..f93507e1 100644 --- a/lib/single-mod-checker.js +++ b/lib/single-mod-checker.js @@ -187,7 +187,7 @@ class modFileChecker { this.populateL10n() this.populateIcon() - this.badges = this.#getBadges() + this.badgeArray = this.#getBadges() this.issues = this.#populateIssues() this.currentLocal = this.#locale() } @@ -208,7 +208,7 @@ class modFileChecker { md5Sum : this.md5Sum, fileDetail : this.fileDetail, issues : this.issues, - badges : this.badges, + badgeArray : this.badgeArray, l10n : this.l10n, modDesc : {}, uuid : this.uuid, @@ -264,14 +264,6 @@ class modFileChecker { } #getBadges() { - const badgeColor = { - broken : 'danger', - problem : 'warning', - noMP : 'secondary', - PCOnly : 'info', - folder : 'primary', - notmod : 'danger', - } const badges = { broken : false, problem : false, @@ -293,11 +285,11 @@ class modFileChecker { const badgeCollection = [] Object.keys(badges).forEach((badge) => { if ( badges[badge] === true ) { - badgeCollection.push(``) + badgeCollection.push(badge) } }) - return badgeCollection.join('') + return badgeCollection } #isFileNameBad() { @@ -777,7 +769,7 @@ class notModFileChecker { pngTexture : [], } - badges = '' + badgeArray = ['broken', 'notmod'] canNotUse = true currentLocale = null diff --git a/modAssist_main.js b/modAssist_main.js index 6b11eb4b..75c537b1 100644 --- a/modAssist_main.js +++ b/modAssist_main.js @@ -282,9 +282,28 @@ let devControls = false /** Upgrade Cache Version Here */ if ( semverGt('1.0.2', mcStore.get('cache_version'))) { - log.log.warning('Invalid Mod Cache (old), resetting.') + log.log.warning('Invalid Mod Cache (very old), resetting.') maCache.clear() log.log.info('Mod Cache Cleared') +} else if ( semverGt('1.9.3', mcStore.get('cache_version'))) { + log.log.debug('Mod Cache 1.9.3 Update Running') + const oldCache = maCache.store + const tagRegEx = /"mod_badge_(.+?)"/g + + Object.keys(oldCache).forEach((key) => { + if ( typeof oldCache[key].badgeArray === 'undefined' ) { + oldCache[key].badgeArray = [] + + if ( typeof oldCache[key].badges !== 'undefined' ) { + const tagMatch = [...oldCache[key].badges.matchAll(tagRegEx)] + + tagMatch.forEach((match) => { oldCache[key].badgeArray.push(match[1].toLowerCase()) }) + delete oldCache[key].badges + } + } + }) + maCache.store = oldCache + } else { log.log.debug('Mod Cache Version Good') } diff --git a/package.json b/package.json index a207a861..3aa31993 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fsg-mod-assistant", - "version": "1.9.2", + "version": "1.9.9", "description": "FSG Farm Sim Mod Assistant", "main": "modAssist_main.js", "homepage": "https://github.com/FSGModding/FSG_Mod_Assistant#readme", diff --git a/renderer/a_changelog.html b/renderer/a_changelog.html index 2dbe442a..35c0cbfc 100644 --- a/renderer/a_changelog.html +++ b/renderer/a_changelog.html @@ -42,6 +42,11 @@

+

2.0.0

+
    +
  • Rework mod filtering to a unified interface
  • +
  • FIX: Add "select active" mods to savegame compare
  • +

1.9.2

  • FIX: Cache cleaning could happen "invisibly", add a timeout
  • diff --git a/renderer/find.html b/renderer/find.html index f21b08ca..378cc57e 100644 --- a/renderer/find.html +++ b/renderer/find.html @@ -36,8 +36,8 @@

    - - + +

diff --git a/renderer/main.html b/renderer/main.html index 3f55aefb..5564215a 100644 --- a/renderer/main.html +++ b/renderer/main.html @@ -64,7 +64,7 @@ vertical-align: middle; } td.folder-icon { - width: 66px; + width: 81px; vertical-align: middle; } td.folder-name { @@ -100,8 +100,8 @@
-
-
+
+

@@ -122,7 +122,7 @@

-
+
@@ -141,14 +141,120 @@

+
+
+
+ + + +
+
+ +
+ +
+ + +
+ +
+
+
+ + + + +
+
+
-
+

-
+
0
diff --git a/renderer/renderJS/assist_ui.js b/renderer/renderJS/assist_ui.js index d58c576b..8828715a 100644 --- a/renderer/renderJS/assist_ui.js +++ b/renderer/renderJS/assist_ui.js @@ -82,16 +82,31 @@ window.mods.receive('fromMain_selectOnlyFilter', (selectMod, filterText) => { }) -let lastLocale = 'en' -let lastQuickLists = {} +let lastLocale = 'en' +let lastQuickLists = {} +let searchStringMap = {} +let searchTagMap = {} window.mods.receive('fromMain_modList', (opts) => { - lastQuickLists = {} + lastQuickLists = {} + searchStringMap = {} + searchTagMap = { + broken : [], + folder : [], + new : [], + nomp : [], + notmod : [], + pconly : [], + problem : [], + recent : [], + update : [], + nonmh : [], + } lastLocale = opts.currentLocale const lastOpenAcc = document.querySelector('.accordion-collapse.show') const lastOpenID = (lastOpenAcc !== null) ? lastOpenAcc.id : null - const lastOpenQ = (lastOpenAcc !== null) ? lastOpenAcc.querySelector('input.mod-row-filter').value : '' + const lastOpenQ = (lastOpenAcc !== null) ? fsgUtil.byId('filter_input').value : '' const scrollStart = window.scrollY const selectedList = ( opts.activeCollection !== '999' && opts.activeCollection !== '0') ? `collection--${opts.activeCollection}` : opts.activeCollection @@ -106,45 +121,61 @@ window.mods.receive('fromMain_modList', (opts) => { opts.modList[collection].mods.forEach((thisMod) => { try { - const extraBadges = [] - const modId = opts.modHub.list.mods[thisMod.fileDetail.shortName] || null - const modVer = opts.modHub.version[modId] || null + const displayBadges = thisMod.badgeArray || [] + const modId = opts.modHub.list.mods[thisMod.fileDetail.shortName] || null + const modVer = opts.modHub.version[modId] || null + const modColUUID = `${collection}--${thisMod.uuid}` sizeOfFolder += thisMod.fileDetail.fileSize if ( Object.keys(thisMod.modDesc.binds).length > 0 ) { if ( typeof opts.bindConflict[collection][thisMod.fileDetail.shortName] !== 'undefined' ) { - extraBadges.push(fsgUtil.badge('danger', 'keys_bad')) + displayBadges.push('keys_bad') } else { - extraBadges.push(fsgUtil.badge('success', 'keys_ok')) + displayBadges.push('keys_ok') } } if ( modVer !== null && thisMod.modDesc.version !== modVer) { - extraBadges.push(fsgUtil.badge('light', 'update')) + displayBadges.push('update') } if ( opts.newMods.includes(thisMod.md5Sum) && !thisMod.canNotUse ) { - extraBadges.push(fsgUtil.badge('success', 'new')) + displayBadges.push('new') } if ( modId !== null && opts.modHub.list.last.includes(modId) ) { - extraBadges.push(fsgUtil.badge('success', 'recent')) + displayBadges.push('recent') } if ( modId === null ) { - extraBadges.push(fsgUtil.badge('dark', 'nonmh')) + displayBadges.push('nonmh') } - let theseBadges = thisMod.badges + extraBadges.join('') + if ( displayBadges.includes('broken') && displayBadges.includes('notmod') ) { + const brokenIdx = displayBadges.indexOf('broken') + displayBadges.splice(brokenIdx, brokenIdx !== -1 ? 1 : 0) + } - if ( theseBadges.match('mod_badge_broken') && theseBadges.match('mod_badge_notmod') ) { - theseBadges = theseBadges.replace(fsgUtil.badge('danger', 'broken'), '') + if ( ! metDepend(thisMod.modDesc.depend, collection, opts.modList[collection].mods) ) { + displayBadges.unshift('depend') } + searchStringMap[modColUUID] = [ + thisMod.fileDetail.shortName, + thisMod.l10n.title, + thisMod.modDesc.author + ].join(' ').toLowerCase() + + displayBadges.forEach((badge) => { + if ( typeof searchTagMap?.[badge]?.push === 'function' ) { + searchTagMap[badge].push(modColUUID) + } + }) + modRows.push(makeModRow( - `${collection}--${thisMod.uuid}`, + modColUUID, thisMod, - theseBadges, - modId, - metDepend(thisMod.modDesc.depend, collection, opts.modList[collection].mods) + displayBadges, + modId )) + } catch (e) { window.log.notice(`Error building mod row: ${e}`, 'main') } @@ -152,12 +183,13 @@ window.mods.receive('fromMain_modList', (opts) => { modTable.push(makeModCollection( collection, - `${opts.modList[collection].name} [${opts.modList[collection].mods.length}] [${fsgUtil.bytesToHR(sizeOfFolder, opts.currentLocale)}]`, + `${opts.modList[collection].name} [${fsgUtil.bytesToHR(sizeOfFolder, opts.currentLocale)}]`, modRows, fsgUtil.notesDefault(opts.notes, collection, 'notes_website'), fsgUtil.notesDefault(opts.notes, collection, 'notes_websiteDL', false), fsgUtil.notesDefault(opts.notes, collection, 'notes_tagline'), - fsgUtil.notesDefault(opts.notes, collection, 'notes_admin') + fsgUtil.notesDefault(opts.notes, collection, 'notes_admin'), + opts.modList[collection].mods.length )) const selectCollName = `${opts.modList[collection].name}${window.mods.getCollDesc(collection)}` @@ -200,6 +232,7 @@ window.mods.receive('fromMain_modList', (opts) => { window.scrollTo(0, scrollStart) } catch { /* nope */ } + select_lib.filter() processL10N() }) @@ -238,9 +271,11 @@ function clientMakeListActive() { } } -function makeModCollection(id, name, modsRows, website, dlEnabled, tagLine, adminPass) { +function makeModCollection(id, name, modsRows, website, dlEnabled, tagLine, adminPass, modCount) { + const totCount = modCount > 999 ? '999+' : modCount return ` +
${totCount}
${fsgUtil.getIconSVG('folder')} @@ -257,46 +292,14 @@ function makeModCollection(id, name, modsRows, website, dlEnabled, tagLine, admi - - - - - ${modsRows.join('')} -
-
-
-
- ${getText('filter_only')} - - -
-
-
-
- - - - - -
-
-
-
- ${getText('select_pick')} - - - -
-
-
-
+ ${modsRows.join('')}
+ ${getText('empty_or_filtered')} ` } - -function makeModRow(id, thisMod, badges, modId, metDepend) { - const theseBadges = ( metDepend ) ? badges : fsgUtil.badge('warning', 'depend') + badges +function makeModRow(id, thisMod, badges, modId) { + const badgeHTML = Array.from(badges, (badge) => fsgUtil.badge(false, badge)) return ` @@ -306,7 +309,7 @@ function makeModRow(id, thisMod, badges, modId, metDepend) { -
${thisMod.fileDetail.shortName}
${fsgUtil.escapeSpecial(thisMod.l10n.title)} - ${fsgUtil.escapeSpecial(thisMod.modDesc.author)}
${theseBadges}
+
${thisMod.fileDetail.shortName}
${fsgUtil.escapeSpecial(thisMod.l10n.title)} - ${fsgUtil.escapeSpecial(thisMod.modDesc.author)}
${badgeHTML.join(' ')}
${fsgUtil.escapeSpecial(thisMod.modDesc.version)}
${( thisMod.fileDetail.fileSize > 0 ) ? fsgUtil.bytesToHR(thisMod.fileDetail.fileSize, lastLocale) : ''} @@ -315,10 +318,8 @@ function makeModRow(id, thisMod, badges, modId, metDepend) { } -function clientClearInput(id) { - const filterId = id.replace('__filter', '') - - select_lib.filter(filterId, '') +function clientClearInput() { + select_lib.filter(null, '') } function clientBatchOperation(mode) { @@ -368,8 +369,8 @@ function clientOpenFarmSim() { window.mods.startFarmSim() } -window.addEventListener('hide.bs.collapse', () => { select_lib.clear_all() }) -window.addEventListener('show.bs.collapse', () => { select_lib.clear_all() }) +window.addEventListener('hide.bs.collapse', () => { select_lib.click_none() }) +window.addEventListener('show.bs.collapse', () => { select_lib.click_none() }) const giantsLED = { filters : [{ vendorId : fsgUtil.led.vendor, productId : fsgUtil.led.product }] } diff --git a/renderer/renderJS/detail_ui.js b/renderer/renderJS/detail_ui.js index c6c40767..37ce5dce 100644 --- a/renderer/renderJS/detail_ui.js +++ b/renderer/renderJS/detail_ui.js @@ -106,24 +106,24 @@ window.mods.receive('fromMain_modRecord', (modRecord, modhubRecord, bindConflict fsgUtil.byId('problems').innerHTML = `${problems.join('')}
` } - const extraBadges = [] + const displayBadges = modRecord.badgeArray || [] if ( Object.keys(modRecord.modDesc.binds).length > 0 ) { if ( typeof bindConflict[modRecord.currentCollection][modRecord.fileDetail.shortName] !== 'undefined' ) { - extraBadges.push(fsgUtil.badge('danger', 'keys_bad')) + displayBadges.push('keys_bad') } else { - extraBadges.push(fsgUtil.badge('success', 'keys_ok')) + displayBadges.push('keys_ok') } } if ( modhubRecord[0] !== null && modhubRecord[1] !== null && modRecord.modDesc.version !== modhubRecord[1]) { - extraBadges.push(fsgUtil.badge('light', 'update')) + displayBadges.push('update') } if ( modhubRecord[2] ) { - extraBadges.push(fsgUtil.badge('success', 'recent')) + displayBadges.push('recent') } if ( modhubRecord[0] === null ) { - extraBadges.push(fsgUtil.badge('dark', 'nonmh')) + displayBadges.push('nonmh') fsgUtil.byId('modhub_link').classList.add('d-none') } else { const modhubLink = `https://www.farming-simulator.com/mod.php?mod_id=${modhubRecord[0]}` @@ -131,16 +131,16 @@ window.mods.receive('fromMain_modRecord', (modRecord, modhubRecord, bindConflict } if ( typeof modRecord.modDesc.depend !== 'undefined' && modRecord.modDesc.depend.length > 0 ) { - extraBadges.push(fsgUtil.badge('success', 'depend_flag')) + displayBadges.push('depend_flag') } - extraBadges.push(modRecord.badges) - let theseBadges = extraBadges.join('') - - if ( theseBadges.match('mod_badge_broken') && theseBadges.match('mod_badge_notmod') ) { - theseBadges = theseBadges.replace(fsgUtil.badge('danger', 'broken'), '') + if ( displayBadges.includes('broken') && displayBadges.includes('notmod') ) { + const brokenIdx = displayBadges.indexOf('broken') + displayBadges.splice(brokenIdx, brokenIdx !== -1 ? 1 : 0) } + const theseBadges = Array.from(displayBadges, (badge) => fsgUtil.badge(false, badge)).join(' ') + textOrHide( 'badges', theseBadges, diff --git a/renderer/renderJS/fsg_util.js b/renderer/renderJS/fsg_util.js index b1819f29..c29cc0fe 100644 --- a/renderer/renderJS/fsg_util.js +++ b/renderer/renderJS/fsg_util.js @@ -25,7 +25,7 @@ const fsgUtil = { case 'x': return '' case 'folder': - return '' + + return '' + ''+ '' + '' + @@ -101,5 +101,20 @@ const fsgUtil = { .replaceAll(/"/g, '"') .replaceAll(/'/g, ''') }, - badge : (color, name, fullName = false) => `${getText(`${(fullName)?'':'mod_badge_'}${name}`)}`, + badgeDefault : { + broken : 'danger', + problem : 'warning', + nomp : 'secondary', + pconly : 'info', + folder : 'primary', + notmod : 'danger', + update : 'light', + keys_bad : 'danger', + keys_ok : 'success', + new : 'success', + recent : 'success', + nonmh : 'dark', + depend : 'warning', + }, + badge : (color, name, fullName = false) => `${getText(`${(fullName)?'':'mod_badge_'}${name}`)}`, } diff --git a/renderer/renderJS/savegame_ui.js b/renderer/renderJS/savegame_ui.js index 8143ce4e..a422d0c2 100644 --- a/renderer/renderJS/savegame_ui.js +++ b/renderer/renderJS/savegame_ui.js @@ -19,6 +19,7 @@ const selectList = { inactive : [], unused : [], nohub : [], + active : [], } const selectCount = { dlc : 0, @@ -29,6 +30,7 @@ const selectCount = { inactive : 0, unused : 0, nohub : 0, + active : 0, } function processL10N() { clientGetL10NEntries() } @@ -76,6 +78,7 @@ window.mods.receive('fromMain_saveInfo', (modList, savegame, modHubList) => { selectList.inactive = [] selectList.unused = [] selectList.nohub = [] + selectList.active = [] selectCount.isloaded = 0 selectCount.dlc = 0 @@ -85,6 +88,7 @@ window.mods.receive('fromMain_saveInfo', (modList, savegame, modHubList) => { selectCount.unused = 0 selectCount.inactive = 0 selectCount.nohub = 0 + selectCount.active = 0 if ( savegame.errorList.length > 0 ) { const errors = [] @@ -175,6 +179,9 @@ window.mods.receive('fromMain_saveInfo', (modList, savegame, modHubList) => { if ( thisModDetail.isModHub === false ) { selectList.nohub.push(`${thisCollection}--${thisUUID}`) } + if ( thisModDetail.isLoaded === true ) { + selectList.active.push(`${thisCollection}--${thisUUID}`) + } } modSetHTML.push(makeLine(thisMod, thisModDetail, savegame.singleFarm)) @@ -185,6 +192,7 @@ window.mods.receive('fromMain_saveInfo', (modList, savegame, modHubList) => { selectCount.nohub = selectList.nohub.length selectCount.inactive = selectList.inactive.length selectCount.unused = selectList.unused.length + selectCount.active = selectList.active.length updateCounts() processL10N() diff --git a/renderer/renderJS/select_lib_ui.js b/renderer/renderJS/select_lib_ui.js index 200de599..31e182b7 100644 --- a/renderer/renderJS/select_lib_ui.js +++ b/renderer/renderJS/select_lib_ui.js @@ -7,7 +7,7 @@ // Selection library, split for readability of main ui script /* exported select_lib */ -/* global fsgUtil */ +/* global fsgUtil searchStringMap searchTagMap */ const select_lib = { last_alt_select : null, @@ -29,7 +29,11 @@ const select_lib = { }) if ( openTable !== false ) { select_lib.open_table(openTable) } }, - clear_range : () => { select_lib.last_select_mod = null; select_lib.last_select_table = null; select_lib.update_color() }, + clear_range : () => { + select_lib.last_select_mod = null + select_lib.last_select_table = null + select_lib.update_color() + }, click_alt : (modID) => { select_lib.last_alt_select = modID const moveButtons = fsgUtil.byId('moveButtonsInt').querySelectorAll('button') @@ -91,16 +95,16 @@ const select_lib = { get_checks : (tableID) => { return document.getElementById(tableID).querySelectorAll('.mod-row-checkbox') }, - bulk_table : (tableID) => { + bulk_table : () => { select_lib.clear_range() select_lib.update_color() - select_lib.filter(tableID) + select_lib.filter() }, change_count : ( newCount ) => { fsgUtil.byId('select_quantity').innerHTML = newCount }, click_only : (tableID, checkList) => { - fsgUtil.byId(`${tableID}__filter`).value = '' + fsgUtil.byId('filter_input').value = '' select_lib.get_checks(tableID).forEach((check) => { const modRow = check.parentElement.parentElement check.checked = checkList.includes(check.id) @@ -108,40 +112,53 @@ const select_lib = { check.checked = false } }) - select_lib.bulk_table(tableID) + select_lib.bulk_table() }, - click_none : (tableID) => { - select_lib.get_checks(tableID).forEach((check) => {check.checked = false}) - select_lib.bulk_table(tableID) + click_none : () => { + fsgUtil.byId('mod-collections').querySelectorAll('.mod-row-checkbox:checked').forEach((check) => { + check.checked = false + }) + select_lib.bulk_table() }, - click_all : (tableID) => { - select_lib.get_checks(tableID).forEach((check) => { - if ( ! check.parentElement.parentElement.classList.contains('d-none') ) { - check.checked = true - } + click_all : () => { + select_lib.get_open_tables().forEach((tableID) => { + select_lib.get_checks(tableID.id).forEach((check) => { + if ( ! check.parentElement.parentElement.classList.contains('d-none') ) { + check.checked = true + } + }) }) - select_lib.bulk_table(tableID) + select_lib.bulk_table() }, - click_invert : (tableID) => { - select_lib.get_checks(tableID).forEach((check) => { - if ( ! check.parentElement.parentElement.classList.contains('d-none') ) { - check.checked = !check.checked - } + click_invert : () => { + select_lib.get_open_tables().forEach((tableID) => { + select_lib.get_checks(tableID.id).forEach((check) => { + if ( ! check.parentElement.parentElement.classList.contains('d-none') ) { + check.checked = !check.checked + } + }) }) - select_lib.bulk_table(tableID) + select_lib.bulk_table() + }, + get_open_tables : () => { + return fsgUtil.byId('mod-collections').querySelectorAll('.collapse.show') }, clear_all : () => { - const allMods = fsgUtil.query('.mod-row') - const moveButtons = fsgUtil.byId('moveButtonsInt').querySelectorAll('button') - const allModChecks = fsgUtil.query('.mod-row-checkbox') - const filterBoxes = fsgUtil.query('.mod-row-filter') - const filterChecks = fsgUtil.query('.mod-row-filter_check') - - filterBoxes.forEach( (thisBox) => { thisBox.value = '' }) - allModChecks.forEach((thisCheck) => { thisCheck.checked = false }) - filterChecks.forEach((thisCheck) => { thisCheck.checked = true }) - moveButtons.forEach( (button) => { button.classList.add('disabled') }) - allMods.forEach( (thisMod) => { thisMod.classList.remove('d-none') }) + const allMods = fsgUtil.query('.mod-row') + const moveButtons = fsgUtil.byId('moveButtonsInt').querySelectorAll('button') + const allModChecks = fsgUtil.query('.mod-row-checkbox') + const filterInput = fsgUtil.byId('filter_input') + const filterTags = fsgUtil.query('.filter_tag_buttons') + const filterOutTags = fsgUtil.query('.filter_out_tag_buttons') + const filterChecks = fsgUtil.query('.mod-row-filter_check') + + filterInput.value = '' + filterTags.forEach( (thisCheck) => { thisCheck.checked = false }) + filterOutTags.forEach((thisCheck) => { thisCheck.checked = false }) + allModChecks.forEach( (thisCheck) => { thisCheck.checked = false }) + filterChecks.forEach( (thisCheck) => { thisCheck.checked = true }) + moveButtons.forEach( (button) => { button.classList.add('disabled') }) + allMods.forEach( (thisMod) => { thisMod.classList.remove('d-none') }) select_lib.clear_range() select_lib.update_color() @@ -178,33 +195,99 @@ const select_lib = { }, filter : (table, forceValue = false) => { if ( forceValue !== false ) { - fsgUtil.byId(`${table}__filter`).value = forceValue + fsgUtil.byId('filter_input').value = forceValue } - const theseMods = fsgUtil.byId(table).querySelectorAll('.mod-row') - const rawSearchTerm = fsgUtil.byId(`${table}__filter`).value.toLowerCase() - const showNonMods = fsgUtil.byId(`${table}__show_non_mod`).checked - const showBroken = fsgUtil.byId(`${table}__show_broken`).checked + + const tagLimit = fsgUtil.byId('filter__tags').querySelectorAll(':checked') + const tagHiders = fsgUtil.byId('filter_out__tags').querySelectorAll(':checked') + const theseMods = fsgUtil.byId('mod-collections').querySelectorAll('.mod-row') + const rawSearchTerm = fsgUtil.byId('filter_input').value.toLowerCase() const inverseSearch = rawSearchTerm.startsWith('!') const searchTerm = ( inverseSearch ) ? rawSearchTerm.substring(1) : rawSearchTerm - fsgUtil.byId(`${table}__filter_clear`).classList[(rawSearchTerm === '') ? 'add' : 'remove']('d-none') - + fsgUtil.byId('tag_filter_count').innerHTML = tagLimit.length + fsgUtil.byId('tag_filter_out_count').innerHTML = tagHiders.length + fsgUtil.byId('filter_clear').classList[(rawSearchTerm === '') ? 'add' : 'remove']('d-none') + + const shownByTags_sets = [] + const hideByTags_array = [] + + let showOnlyTags = false + + if ( tagHiders.length > 0 ) { + tagHiders.forEach((element) => { + const thisTag = element.id.split('__')[1] + hideByTags_array.push(...searchTagMap[thisTag]) + }) + } + + const hideByTags_set = new Set(hideByTags_array) + + if ( tagLimit.length > 0 ) { + tagLimit.forEach((element) => { + const thisTag = element.id.split('__')[1] + shownByTags_sets.push(searchTagMap[thisTag]) + }) + + showOnlyTags = select_lib.setIntersection(shownByTags_sets) + } + theseMods.forEach((modRow) => { + const modRowUUID = modRow.id + modRow.classList.remove('d-none') if ( modRow.querySelector('.mod-row-checkbox').checked ) { return } - const modBadges = modRow.querySelector('.issue_badges').innerHTML - - if ( !showBroken && modBadges.match('mod_badge_broken') ) { modRow.classList.add('d-none'); return } - if ( !showNonMods && modBadges.match('mod_badge_notmod') ) { modRow.classList.add('d-none'); return } + if ( hideByTags_set.has(modRowUUID) ) { modRow.classList.add('d-none'); return } - if ( searchTerm.length < 2 ) { modRow.classList.remove('d-none'); return } + if ( showOnlyTags !== false ) { + if ( ! showOnlyTags.has(modRowUUID) ) { modRow.classList.add('d-none'); return } + } + + if ( searchTerm.length < 2 ) { return } - const modText = modRow.querySelector('td:nth-child(3)').innerText.toLowerCase() + const modText = searchStringMap[modRowUUID] const showMe = ( inverseSearch ) ? !modText.match(searchTerm) : modText.match(searchTerm) modRow.classList[(showMe?'remove':'add')]('d-none') }) + + fsgUtil.query('.mod-table-folder-detail').forEach((table) => { + const shownRows = table.querySelectorAll('.mod-row:not(.d-none)') + if ( shownRows.length === 0 ) { + table.querySelector('span.no-mods-found').classList.remove('d-none') + } else { + table.querySelector('span.no-mods-found').classList.add('d-none') + } + + }) + }, + tag_reset : () => { + const filterTags = fsgUtil.query('.filter_tag_buttons') + + filterTags.forEach( (thisCheck) => { thisCheck.checked = false }) + select_lib.filter() + }, + out_tag_reset : () => { + const filterTags = fsgUtil.query('.filter_out_tag_buttons') + + filterTags.forEach( (thisCheck) => { thisCheck.checked = false }) + select_lib.filter() + }, + setIntersection : (sets) => { + sets.sort((a, b) => b.length - a.length) + + const smallestSet = sets[sets.length-1] + const returnSet = new Set(sets[sets.length-1]) + + if ( sets.length === 1 ) { return returnSet } + + smallestSet.forEach((thisMod) => { + for (let i = 0; i < sets.length-1; i++ ) { + if ( ! sets[i].includes(thisMod) ) { returnSet.delete(thisMod) } + } + }) + return returnSet }, } \ No newline at end of file diff --git a/renderer/savegame.html b/renderer/savegame.html index da584ec4..249adf91 100644 --- a/renderer/savegame.html +++ b/renderer/savegame.html @@ -61,6 +61,7 @@

+

diff --git a/test/mod-reader-test.js b/test/mod-reader-test.js index 0e98f721..c8ff7714 100644 --- a/test/mod-reader-test.js +++ b/test/mod-reader-test.js @@ -40,10 +40,9 @@ folderContents.forEach((thisFile) => { logger, () => { return 'en'} ) - const badgeNames = Array.from(thisMod.badges.matchAll(/"mod_badge_(.+?)"/g), (m) => `${m[1]}`) console.log(` Giants HASH : ${thisMod.giantsHash}`) console.log(` Issues : ${thisMod.issues.join(', ')}`) - console.log(` Badges : ${badgeNames.join(', ')}`) + console.log(` Badges : ${thisMod.badgeArray.join(', ')}`) console.log(` Extra : ${thisMod.fileDetail.extraFiles.join(', ')}`) } catch (e) { console.log(` Unable to read ${thisFile} :: ${e}`) diff --git a/translations/de.json b/translations/de.json index 843b4524..69df937a 100644 --- a/translations/de.json +++ b/translations/de.json @@ -158,10 +158,6 @@ "select_none__title": "Alle abwählen", "select_none": "keine", "select_pick": "Wählen Sie", - "show_broken__title": "Kaputte Mods anzeigen", - "show_broken": "Gebrochene anzeigen", - "show_non_mod__title": "Nicht-Mod-Dateien anzeigen", - "show_non_mod": "Nicht-Mods anzeigen", "status-processing-title": "Verarbeitung von Mods...", "status-set-list-title": "Spiel-Mod-Ordner einstellen...", "tray_quit": "Beenden Sie", @@ -290,5 +286,9 @@ "folder_up_button__title": "Ordner nach oben verschieben", "folder_down_button__title": "Ordner nach unten verschieben", "folder_bot_button__title": "Ordner nach unten verschieben", - "translate_blurb_tagline": "Unterstützen Sie die Übersetzungsarbeit auf" + "translate_blurb_tagline": "Unterstützen Sie die Übersetzungsarbeit auf", + "filter_badges": "Begrenzung auf Tags", + "filter_out_badges": "Hide Tags", + "filter_tag_reset": "RESET", + "empty_or_filtered": "Leere Sammlung oder alle Mods durch Filter versteckt" } \ No newline at end of file diff --git a/translations/en.json b/translations/en.json index 1e908144..503536a2 100644 --- a/translations/en.json +++ b/translations/en.json @@ -77,7 +77,7 @@ "mod_badge_broken__title" : "This mod is broken", "mod_badge_broken" : "broken", "mod_badge_folder__title" : "This is a folder", - "mod_badge_folder" : "Folder", + "mod_badge_folder" : "folder", "mod_badge_new__title" : "This file is new since the last scan", "mod_badge_new" : "new", "mod_badge_nomp__title" : "This can't be used in multiplayer", @@ -158,10 +158,6 @@ "select_none__title" : "Deselect All (SHIFT+CTRL+A)", "select_none" : "none", "select_pick" : "Select", - "show_broken__title" : "Show Broken Mods", - "show_broken" : "Show Broken", - "show_non_mod__title" : "Show Non Mod Files", - "show_non_mod" : "Show Non-Mods", "status-processing-title" : "Processing Mods...", "status-set-list-title" : "Setting Game Mod Folder...", "tray_quit" : "Quit", @@ -290,5 +286,9 @@ "folder_up_button__title" : "Move folder up", "folder_down_button__title" : "Move folder down", "folder_bot_button__title" : "Move folder to bottom", - "translate_blurb_tagline" : "Feel free to support the translation effort on" + "translate_blurb_tagline" : "Feel free to support the translation effort on", + "filter_badges" : "Limit to Tags", + "filter_out_badges" : "Hide Tags", + "filter_tag_reset" : "RESET", + "empty_or_filtered" : "Empty collection or all mods hidden by filters" } \ No newline at end of file diff --git a/translations/es.json b/translations/es.json index d63eedb0..a6bab7d0 100644 --- a/translations/es.json +++ b/translations/es.json @@ -158,10 +158,6 @@ "select_none__title": "Deseleccionar todo", "select_none": "ninguno", "select_pick": "Seleccione", - "show_broken__title": "Mostrar mods rotos", - "show_broken": "Mostrar roto", - "show_non_mod__title": "Mostrar archivos no mod", - "show_non_mod": "Mostrar los no-mods", "status-processing-title": "Procesamiento de mods...", "status-set-list-title": "Configuración de la carpeta de mods del juego...", "tray_quit": "Quit", @@ -290,5 +286,9 @@ "folder_up_button__title": "Mover carpeta arriba", "folder_down_button__title": "Mover carpeta abajo", "folder_bot_button__title": "Mover carpeta al fondo", - "translate_blurb_tagline": "No dude en apoyar el esfuerzo de traducción en" + "translate_blurb_tagline": "No dude en apoyar el esfuerzo de traducción en", + "filter_badges": "Limitar a etiquetas", + "filter_out_badges": "Ocultar etiquetas", + "filter_tag_reset": "RESET", + "empty_or_filtered": "Colección vacía o todos los mods ocultos por filtros" } \ No newline at end of file diff --git a/translations/fr.json b/translations/fr.json index d49f12cc..67abd442 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -158,10 +158,6 @@ "select_none__title": "Désélectionner tout (SHIFT+CTRL+A)", "select_none": "aucun", "select_pick": "Sélectionnez", - "show_broken__title": "Afficher les mods cassés", - "show_broken": "Montrer cassé", - "show_non_mod__title": "Afficher les fichiers non mod", - "show_non_mod": "Afficher les non-mods", "status-processing-title": "Modes de traitement...", "status-set-list-title": "Réglage du dossier de modélisation du jeu...", "tray_quit": "Arrêtez", @@ -290,5 +286,9 @@ "folder_up_button__title": "Déplacer le dossier vers le haut", "folder_down_button__title": "Déplacer le dossier vers le bas", "folder_bot_button__title": "Déplacer le dossier en bas", - "translate_blurb_tagline": "N'hésitez pas à soutenir l'effort de traduction sur" + "translate_blurb_tagline": "N'hésitez pas à soutenir l'effort de traduction sur", + "filter_badges": "Limite aux balises", + "filter_out_badges": "Hide Tags", + "filter_tag_reset": "RESET", + "empty_or_filtered": "Collection vide ou tous les mods cachés par des filtres" } \ No newline at end of file diff --git a/translations/nl.json b/translations/nl.json index ba0f34a9..4a15b32d 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -158,10 +158,6 @@ "select_none__title": "Deselecteer alles (SHIFT+CTRL+A)", "select_none": "geen", "select_pick": "Selecteer", - "show_broken__title": "Toon Gebroken Mods", - "show_broken": "Toon Gebroken", - "show_non_mod__title": "Toon Non Mod Files", - "show_non_mod": "Toon Non-Mods", "status-processing-title": "Mods verwerken...", "status-set-list-title": "Game Mod Map instellen...", "tray_quit": "Stop", @@ -290,5 +286,9 @@ "folder_up_button__title": "Verplaats map naar boven", "folder_down_button__title": "Verplaats map naar beneden", "folder_bot_button__title": "Verplaats map naar beneden", - "translate_blurb_tagline": "Voel je vrij om de vertaling te steunen op" + "translate_blurb_tagline": "Voel je vrij om de vertaling te steunen op", + "filter_badges": "Beperk tot Tags", + "filter_out_badges": "Hide Tags", + "filter_tag_reset": "RESET", + "empty_or_filtered": "Lege collectie of alle mods verborgen door filters" } \ No newline at end of file diff --git a/translations/pl.json b/translations/pl.json index 9b62da32..21212da1 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -158,10 +158,6 @@ "select_none__title": "Odznacz wszystko", "select_none": "Brak", "select_pick": "Wybierz", - "show_broken__title": "Pokaż uszkodzone mody", - "show_broken": "Pokaż uszkodzone", - "show_non_mod__title": "Pokaż pliki nie-mody", - "show_non_mod": "Pokaż nie-mody", "status-processing-title": "Przetwarzanie modów...", "status-set-list-title": "Ustawianie folderu z modami...", "tray_quit": "Zamknij", @@ -290,5 +286,9 @@ "folder_up_button__title": "Przesuń folder w górę", "folder_down_button__title": "Przesuń folder w dół", "folder_bot_button__title": "Przesuń folder na dół", - "translate_blurb_tagline": "Zachęcamy do wspierania wysiłków na rzecz tłumaczenia na" + "translate_blurb_tagline": "Zachęcamy do wspierania wysiłków na rzecz tłumaczenia na", + "filter_badges": "Limit na tagi", + "filter_out_badges": "Hide Tags", + "filter_tag_reset": "RESET", + "empty_or_filtered": "Pusta kolekcja lub wszystkie mody ukryte przez filtry" } \ No newline at end of file diff --git a/translations/pt.json b/translations/pt.json index dce2c8db..6a3796e4 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -158,10 +158,6 @@ "select_none__title": "Desmarcar todos", "select_none": "Nenhum", "select_pick": "Selecione", - "show_broken__title": "Mostrar mods quebrados", - "show_broken": "Mostrar quebrado", - "show_non_mod__title": "Mostrar arquivos não mod", - "show_non_mod": "Mostrar não-mods", "status-processing-title": "Modificando processamento...", "status-set-list-title": "Configurações de pasta de mods de jogo...", "tray_quit": "Desistir", @@ -290,5 +286,9 @@ "folder_up_button__title": "Mover pasta para cima", "folder_down_button__title": "Mover pasta para baixo", "folder_bot_button__title": "Mover pasta para o fundo", - "translate_blurb_tagline": "Sinta-se à vontade para apoiar o esforço de tradução em" + "translate_blurb_tagline": "Sinta-se à vontade para apoiar o esforço de tradução em", + "filter_badges": "Limite a etiquetas", + "filter_out_badges": "Esconder Etiquetas", + "filter_tag_reset": "RESET", + "empty_or_filtered": "Colecção vazia ou todos os mods escondidos por filtros" } \ No newline at end of file diff --git a/translations/ru.json b/translations/ru.json index f3b1c029..a2604e6a 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -158,10 +158,6 @@ "select_none__title": "Отменить весь выбор (SHIFT+CTRL+A)", "select_none": "ничего", "select_pick": "Выбрать", - "show_broken__title": "Показать неработающие моды", - "show_broken": "Неработающие", - "show_non_mod__title": "Показать файлы, не являющиеся модами", - "show_non_mod": "Не моды", "status-processing-title": "Обработка модов…", "status-set-list-title": "Настройка папки с игровыми модами…", "tray_quit": "Выйти", @@ -290,5 +286,9 @@ "folder_up_button__title": "Переместить папку выше", "folder_down_button__title": "Переместить папку ниже", "folder_bot_button__title": "Переместить папку в самый низ", - "translate_blurb_tagline": "Помочь с работой над переводом можно на сайте" + "translate_blurb_tagline": "Помочь с работой над переводом можно на сайте", + "filter_badges": "Ограничение по тегам", + "filter_out_badges": "Скрыть теги", + "filter_tag_reset": "СБРОС", + "empty_or_filtered": "Пустая коллекция или все моды скрыты фильтрами" } \ No newline at end of file