mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Replace forEach() with for()
This commit is contained in:
parent
01502363ab
commit
6cfff0274d
@ -73,7 +73,8 @@ export class ControllerShortcut {
|
|||||||
const pressed: boolean[] = [];
|
const pressed: boolean[] = [];
|
||||||
let otherButtonPressed = false;
|
let otherButtonPressed = false;
|
||||||
|
|
||||||
gamepad.buttons.forEach((button, index) => {
|
const entries = gamepad.buttons.entries();
|
||||||
|
for (const [index, button] of entries) {
|
||||||
// Only add the newly pressed button to the array (holding doesn't count)
|
// Only add the newly pressed button to the array (holding doesn't count)
|
||||||
if (button.pressed && index !== GamepadKey.HOME) {
|
if (button.pressed && index !== GamepadKey.HOME) {
|
||||||
otherButtonPressed = true;
|
otherButtonPressed = true;
|
||||||
@ -84,7 +85,7 @@ export class ControllerShortcut {
|
|||||||
setTimeout(() => ControllerShortcut.runAction(actions[index]!), 0);
|
setTimeout(() => ControllerShortcut.runAction(actions[index]!), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
ControllerShortcut.buttonsStatus[gamepadIndex] = pressed;
|
ControllerShortcut.buttonsStatus[gamepadIndex] = pressed;
|
||||||
return otherButtonPressed;
|
return otherButtonPressed;
|
||||||
|
@ -130,6 +130,8 @@ export class GameBar {
|
|||||||
|
|
||||||
// Reset all states
|
// Reset all states
|
||||||
reset() {
|
reset() {
|
||||||
this.actions.forEach(action => action.reset());
|
for (const action of this.actions) {
|
||||||
|
action.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -835,10 +835,10 @@ true` + text;
|
|||||||
[UiSection.MOST_POPULAR]: GamePassCloudGallery.MOST_POPULAR,
|
[UiSection.MOST_POPULAR]: GamePassCloudGallery.MOST_POPULAR,
|
||||||
};
|
};
|
||||||
|
|
||||||
PREF_HIDE_SECTIONS.forEach(section => {
|
for (const section of PREF_HIDE_SECTIONS) {
|
||||||
const galleryId = sections[section];
|
const galleryId = sections[section];
|
||||||
galleryId && siglIds.push(galleryId);
|
galleryId && siglIds.push(galleryId);
|
||||||
});
|
};
|
||||||
|
|
||||||
const checkSyntax = siglIds.map(item => `siglId === "${item}"`).join(' || ');
|
const checkSyntax = siglIds.map(item => `siglId === "${item}"`).join(' || ');
|
||||||
|
|
||||||
|
@ -219,9 +219,10 @@ export class StreamBadges {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const $container = CE('div', {class: 'bx-badges'});
|
const $container = CE('div', {class: 'bx-badges'});
|
||||||
BADGES.forEach(item => {
|
|
||||||
|
for (const item of BADGES) {
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let $badge: HTMLElement;
|
let $badge: HTMLElement;
|
||||||
@ -232,7 +233,7 @@ export class StreamBadges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$container.appendChild($badge);
|
$container.appendChild($badge);
|
||||||
});
|
};
|
||||||
|
|
||||||
this.$container = $container;
|
this.$container = $container;
|
||||||
await this.start();
|
await this.start();
|
||||||
|
@ -221,9 +221,10 @@ export class StreamUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const observer = new MutationObserver(mutationList => {
|
const observer = new MutationObserver(mutationList => {
|
||||||
mutationList.forEach(item => {
|
let item: MutationRecord;
|
||||||
|
for (item of mutationList) {
|
||||||
if (item.type !== 'childList') {
|
if (item.type !== 'childList') {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.addedNodes.forEach(async $node => {
|
item.addedNodes.forEach(async $node => {
|
||||||
@ -263,7 +264,7 @@ export class StreamUiHandler {
|
|||||||
// Handle System Menu bar
|
// Handle System Menu bar
|
||||||
StreamUiHandler.handleSystemMenu($elm);
|
StreamUiHandler.handleSystemMenu($elm);
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
observer.observe($screen, {subtree: true, childList: true});
|
observer.observe($screen, {subtree: true, childList: true});
|
||||||
|
@ -177,8 +177,9 @@ export class NavigationDialogManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
calculateSelectBoxes($root: HTMLElement) {
|
calculateSelectBoxes($root: HTMLElement) {
|
||||||
const $selects = $root.querySelectorAll('.bx-select:not([data-calculated]) select');
|
const selects = Array.from($root.querySelectorAll('.bx-select:not([data-calculated]) select'));
|
||||||
$selects.forEach($select => {
|
|
||||||
|
for (const $select of selects) {
|
||||||
const $parent = $select.parentElement! as HTMLElement;
|
const $parent = $select.parentElement! as HTMLElement;
|
||||||
|
|
||||||
// Don't apply to select.bx-full-width elements
|
// Don't apply to select.bx-full-width elements
|
||||||
@ -205,7 +206,7 @@ export class NavigationDialogManager {
|
|||||||
// Set min-width
|
// Set min-width
|
||||||
$label.style.minWidth = width + 'px';
|
$label.style.minWidth = width + 'px';
|
||||||
$parent.dataset.calculated = 'true';
|
$parent.dataset.calculated = 'true';
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(event: Event) {
|
handleEvent(event: Event) {
|
||||||
|
@ -121,9 +121,12 @@ export function createButton<T=HTMLButtonElement>(options: BxButton): T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const style = (options.style || 0) as number;
|
const style = (options.style || 0) as number;
|
||||||
style && ButtonStyleIndices.forEach((index: keyof typeof ButtonStyleClass) => {
|
if (style) {
|
||||||
|
let index: keyof typeof ButtonStyleClass;
|
||||||
|
for (index of ButtonStyleIndices) {
|
||||||
(style & index) && $btn.classList.add(ButtonStyleClass[index] as string);
|
(style & index) && $btn.classList.add(ButtonStyleClass[index] as string);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
options.classes && $btn.classList.add(...options.classes);
|
options.classes && $btn.classList.add(...options.classes);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user