Skip to content

Commit

Permalink
Hide patches preview for unselected containers
Browse files Browse the repository at this point in the history
  • Loading branch information
SalimOfShadow committed May 7, 2024
1 parent 7ae3cff commit feba1cc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions js/dllpatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
let toolVersion = '';
let selectedContainer = '';
const containersList = [];
const inputElArray = [];
// form labels often need unique IDs - this can be used to generate some
window.Patcher_uniqueid = 0;
var createID = function() {
Expand Down Expand Up @@ -804,8 +805,7 @@ class PatchContainer {
const tooltip = (patch.tooltip || '').replace(/"/g, "'");

if (type === 'regular') {
console.log("Regular fired");
toolVersion = 'regular';
toolVersion = 'regular';
filledJSON = new StandardJSON({
gameCode: gameCode,
dateCode: datecode,
Expand Down Expand Up @@ -903,7 +903,7 @@ class PatchContainer {
this.forceLoadTexts = [];
this.forceLoadButtons = [];
this.matchSuccessText = [];
this.containerIndex = containersList.length; // Used only to selecting the first container
this.containerIndex = containersList.length; // Used only for selecting the first container

for (var i = 0; i < this.patchers.length; i++) {
var checkboxId = createID();
Expand All @@ -922,6 +922,7 @@ class PatchContainer {
listItem.appendChild(forceButton);

var input = createInput('checkbox', checkboxId, 'patchPreviewToggle');
inputElArray.push(input);
listItem.appendChild(input);
var patchPreviews = createElementClass('ul', 'patchPreview');
for (var j = 0; j < this.patchers[i].mods.length; j++) {
Expand Down Expand Up @@ -1048,7 +1049,6 @@ class PatchContainer {

const activateContainer = (container) => {
selectedContainer = container;
console.log(`activateContainer fired on ${container.id}`);
container.style.opacity = 1;
container.style.userSelect = "auto";
container.querySelectorAll('*').forEach(child => {
Expand All @@ -1057,19 +1057,20 @@ class PatchContainer {
};

const deactivateContainer = (container) => {
console.log(`deactivateContainer fired on ${container.id}`);
container.style.opacity = 0.4;
container.style.userSelect = "none";
setTimeout(() => {
container.querySelectorAll('*').forEach(child => {
child.style.pointerEvents = "none";
});
}, 10); // Use async await instead
inputElArray.forEach((inputEl) => {
inputEl.checked = false; // Hide patches preview
})
};

const handleContainerClick = (container) => {
if (container === selectedContainer) {
console.log("You clicked an already selected container, returning.");
return;
} else {
activateContainer(container);
Expand Down

0 comments on commit feba1cc

Please sign in to comment.