Skip to content

Commit

Permalink
Merge pull request #48 from FSGModding/shared_filter
Browse files Browse the repository at this point in the history
Overhaul mod filtering
  • Loading branch information
jtsage authored Jan 25, 2023
2 parents bd0b4c3 + 37f25f9 commit 89f77d1
Show file tree
Hide file tree
Showing 21 changed files with 420 additions and 191 deletions.
18 changes: 5 additions & 13 deletions lib/single-mod-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -293,11 +285,11 @@ class modFileChecker {
const badgeCollection = []
Object.keys(badges).forEach((badge) => {
if ( badges[badge] === true ) {
badgeCollection.push(`<span class="badge bg-${badgeColor[badge]}"><l10n name="mod_badge_${badge}"></l10n></span>`)
badgeCollection.push(badge)
}
})

return badgeCollection.join('')
return badgeCollection
}

#isFileNameBad() {
Expand Down Expand Up @@ -777,7 +769,7 @@ class notModFileChecker {
pngTexture : [],
}

badges = '<span class="badge bg-danger"><l10n name="mod_badge_broken"></l10n></span><span class="badge bg-danger"><l10n name="mod_badge_notmod"></l10n></span>'
badgeArray = ['broken', 'notmod']
canNotUse = true
currentLocale = null

Expand Down
21 changes: 20 additions & 1 deletion modAssist_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions renderer/a_changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ <h2 class="ps-2 mastHead"><l10n name="app_name"></l10n> <l10n class="ver" name="
<div class="row">
<div class="col-auto"><img style="width: auto; height: 200px" src="img/sidebar.png"></div>
<div class="col">
<h4>2.0.0</h4>
<ul>
<li>Rework mod filtering to a unified interface</li>
<li>FIX: Add "select active" mods to savegame compare</li>
</ul>
<h4>1.9.2</h4>
<ul>
<li>FIX: Cache cleaning could happen "invisibly", add a timeout</li>
Expand Down
4 changes: 2 additions & 2 deletions renderer/find.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ <h2 class="ps-2 mastHead"><l10n name="app_name"></l10n> <l10n class="ver" name="

<div class="input-group input-group-sm mb-4">
<span class="input-group-text bg-gradient"><l10n name="filter_only"></l10n></span>
<input type="text" id="mods__filter" onkeyup="clientFilter()" class="form-control mod-row-filter">
<span id="mods__filter_clear" onclick="clientClearInput()" class="form-control-clear gg-erase form-control-feedback position-absolute d-none" style="right:10px; cursor:pointer; z-index:100; top:5px; color:black;"></span>
<input type="text" id="mods__filter" onkeyup="clientFilter()" class="form-control mod-row-filter rounded-end">
<span id="mods__filter_clear" onclick="clientClearInput()" class="form-control-clear bi bi-eraser form-control-feedback position-absolute d-none" style="right:10px; cursor:pointer; z-index:100; top:5px; color:black;"></span>
</div>

<table class="w-100 py-0 my-0 table table-sm table-hover table-striped" id="full_table"></table>
Expand Down
118 changes: 112 additions & 6 deletions renderer/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
vertical-align: middle;
}
td.folder-icon {
width: 66px;
width: 81px;
vertical-align: middle;
}
td.folder-name {
Expand Down Expand Up @@ -100,8 +100,8 @@
<body class="d-flex flex-column h-100 overflow-custom2">
<main class="flex-shrink-0">
<div class="container-fluid px-0 user-select-none">
<div class="fixed-top pt-2 pb-2 bg-body" id="main-header">
<div class="row w-100 mb-2">
<div class="fixed-top pt-2 bg-body" id="main-header">
<div class="row w-100 mb-1">
<div class="col-6 border-bottom">
<h2 class="ps-2 mastHead">
<l10n name="app_name"></l10n> <l10n class="ver" name="app_version"></l10n>
Expand All @@ -122,7 +122,7 @@ <h2 class="ps-2 mastHead">
</div>
</div>

<div class="row px-3 pt-1"><!-- source mods -->
<div class="row px-3 py-1"><!-- source mods -->
<div class="col">
<div class="btn-group d-flex h-100" role="group">
<button type="button" style="line-height: 1.1em" class="btn btn-sm btn-success" onclick="mods.addFolder()"><i class="bi bi-folder-plus"></i> <l10n class="small" name="folder_add"></l10n></button>
Expand All @@ -141,14 +141,120 @@ <h2 class="ps-2 mastHead">
<button class="btn btn-success btn-sm w-100 h-100" style="line-height: 1.1em" type="button" onclick="mods.versionCheck()"><l10n name="version_check"></l10n></button>
</div>
</div><!-- end: source mods-->
<div class="row py-1 px-3 border-top border-bottom">
<div class="col">
<div class="input-group input-group-sm mb-0">
<span class="input-group-text bg-gradient"><l10n name="filter_only"></l10n></span>
<input type="text" id="filter_input" onkeyup="select_lib.filter()" class="form-control mod-row-filter rounded-end">
<span id="filter_clear" onclick="clientClearInput()" class="form-control-clear bi bi-eraser form-control-feedback position-absolute d-none" style="right:10px; cursor:pointer; z-index:100; top:5px; color:black;"></span>
</div>
</div>

<div class="col col-auto">
<div class="dropdown">
<button type="button" class="btn btn-sm btn-primary pe-3 dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-auto-close="outside">
<l10n name="filter_out_badges"></l10n>
<span class="position-absolute top-50 start-100 translate-middle badge rounded-pill bg-white text-black" id="tag_filter_out_count">0</span>
</button>
<div class="dropdown-menu px-0 py-0 mt-1">
<div id="filter_out__tags" class="btn-group-vertical btn-group-sm w-100">
<button class="btn btn-outline-warning text-center" onclick="select_lib.out_tag_reset()"><l10n name="filter_tag_reset"></l10n></button>

<input type="checkbox" id="tag_filter_out__broken" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__broken"><l10n name="mod_badge_broken"></l10n></label>

<input type="checkbox" id="tag_filter_out__folder" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__folder"><l10n name="mod_badge_folder"></l10n></label>

<input type="checkbox" id="tag_filter_out__new" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__new"><l10n name="mod_badge_new"></l10n></label>

<input type="checkbox" id="tag_filter_out__nomp" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__nomp"><l10n name="mod_badge_nomp"></l10n></label>

<input type="checkbox" id="tag_filter_out__notmod" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__notmod"><l10n name="mod_badge_notmod"></l10n></label>

<input type="checkbox" id="tag_filter_out__pconly" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__pconly"><l10n name="mod_badge_pconly"></l10n></label>

<input type="checkbox" id="tag_filter_out__problem" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__problem"><l10n name="mod_badge_problem"></l10n></label>

<input type="checkbox" id="tag_filter_out__recent" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__recent"><l10n name="mod_badge_recent"></l10n></label>

<input type="checkbox" id="tag_filter_out__update" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__update"><l10n name="mod_badge_update"></l10n></label>

<input type="checkbox" id="tag_filter_out__nonmh" onchange="select_lib.filter()" class="btn-check filter_out_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter_out__nonmh"><l10n name="mod_badge_nonmh"></l10n></label>
</div>
</div>
</div>
</div>


<div class="col col-auto">
<div class="dropdown">
<button type="button" class="btn btn-sm btn-primary pe-3 dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-auto-close="outside">
<l10n name="filter_badges"></l10n>
<span class="position-absolute top-50 start-100 translate-middle badge rounded-pill bg-white text-black" id="tag_filter_count">0</span>
</button>
<div class="dropdown-menu px-0 py-0 mt-1">
<div id="filter__tags" class="btn-group-vertical btn-group-sm w-100">
<button class="btn btn-outline-warning text-center" onclick="select_lib.tag_reset()"><l10n name="filter_tag_reset"></l10n></button>

<input type="checkbox" id="tag_filter__broken" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__broken"><l10n name="mod_badge_broken"></l10n></label>

<input type="checkbox" id="tag_filter__folder" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__folder"><l10n name="mod_badge_folder"></l10n></label>

<input type="checkbox" id="tag_filter__new" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__new"><l10n name="mod_badge_new"></l10n></label>

<input type="checkbox" id="tag_filter__nomp" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__nomp"><l10n name="mod_badge_nomp"></l10n></label>

<input type="checkbox" id="tag_filter__notmod" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__notmod"><l10n name="mod_badge_notmod"></l10n></label>

<input type="checkbox" id="tag_filter__pconly" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__pconly"><l10n name="mod_badge_pconly"></l10n></label>

<input type="checkbox" id="tag_filter__problem" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__problem"><l10n name="mod_badge_problem"></l10n></label>

<input type="checkbox" id="tag_filter__recent" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__recent"><l10n name="mod_badge_recent"></l10n></label>

<input type="checkbox" id="tag_filter__update" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__update"><l10n name="mod_badge_update"></l10n></label>

<input type="checkbox" id="tag_filter__nonmh" onchange="select_lib.filter()" class="btn-check filter_tag_buttons" autocomplete="off">
<label class="btn btn-outline-light" for="tag_filter__nonmh"><l10n name="mod_badge_nonmh"></l10n></label>
</div>
</div>
</div>
</div>
<div class="col col-auto">
<div class="btn-group btn-group-sm input-group input-group-sm">
<span class="input-group-text"><l10n name="select_pick"></l10n></span>
<button class="btn btn-btn btn-outline-light" onclick="select_lib.click_none()"><l10n name="select_none"></l10n></button>
<button class="btn btn-btn btn-outline-light" onclick="select_lib.click_all()"><l10n name="select_all"></l10n></button>
<button class="btn btn-btn btn-outline-light" onclick="select_lib.click_invert()"><l10n name="select_invert"></l10n></button>
</div>
</div>
</div>
</div>

<div class="row overflow-hidden px-2" style="margin-top: 105px;">
<div class="row overflow-hidden px-2" style="margin-top: 135px;">
<div class="col-10">
<table id="mod-collections" class="w-100 table accordion border-top my-2"></table><br />
</div>
<div class="col-2 p-0"><!-- buttons -->
<div id="moveButtons" class="px-2" style="height: calc(100vh - 152px); position: fixed; top: 112px;">
<div id="moveButtons" class="px-2" style="height: calc(100vh - 178px); position: fixed; top: 140px;">
<div class="badge bg-dark bg-gradient d-block mb-2 mx-auto"><l10n class="fw-normal" name="select_quantity"></l10n> <span id="select_quantity">0</span></div>
<div id="moveButtonsInt" style="height: calc(100% - 28px);">
<button onclick="clientBatchOperation('move')" type="button" class="operation_button w-100 mb-1 btn btn-success rounded-4 disabled"><i class="bi bi-file-earmark-arrow-down"></i><br /><l10n class="small" name="move_to_list"></l10n></button>
Expand Down
Loading

0 comments on commit 89f77d1

Please sign in to comment.