Skip to content

Commit ca8cc08

Browse files
author
Kiosk
committed
fix: confirm dialogs use gamepadConfirm, async handler fixes
1 parent 67df3f0 commit ca8cc08

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

game-menu.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@ <h3 style="font-size:16px;font-weight:600;color:#fff;margin:0;">Upload ROM</h3>
21872187
btn.onclick = async (e) => {
21882188
e.stopPropagation();
21892189
const name = btn.dataset.name;
2190-
if (!confirm('Delete save file?\n\n' + name + '\n\nThis cannot be undone.')) return;
2190+
const cOk = window.gamepadConfirm ? await window.gamepadConfirm('Delete save file?\n\n' + name) : confirm('Delete save file?'); if (!cOk) return;
21912191
try {
21922192
const resp = await fetch('/api/saves/' + btn.dataset.core + '/' + btn.dataset.game, { method: 'DELETE' });
21932193
if (resp.ok) {
@@ -2269,7 +2269,7 @@ <h3 style="font-size:16px;font-weight:600;color:#fff;margin:0;">Upload ROM</h3>
22692269
btn.onclick = async (e) => {
22702270
e.stopPropagation();
22712271
const name = btn.dataset.name;
2272-
if (!confirm('Delete ROM?\\n\\n' + name + '\\n\\nThis cannot be undone.')) return;
2272+
const rOk = window.gamepadConfirm ? await window.gamepadConfirm('Delete ROM?\n\n' + name) : confirm('Delete ROM?'); if (!rOk) return;
22732273
try {
22742274
const resp = await fetch('/api/delete-rom', {
22752275
method: 'POST',
@@ -2504,15 +2504,15 @@ <h3 style="font-size:16px;font-weight:600;color:#fff;margin:0;">Upload ROM</h3>
25042504
this.dispatchEvent(new CustomEvent('settingchange', { detail: { setting: 'perf', value: { system, settings: values } }, bubbles: true }));
25052505
};
25062506

2507-
revertBtn.onclick = () => {
2507+
revertBtn.onclick = async () => {
25082508
if (!this._perfSavedSnapshot) return;
2509-
if (!confirm('Revert unsaved changes?')) return;
2509+
const rvOk = window.gamepadConfirm ? await window.gamepadConfirm('Revert unsaved changes?') : confirm('Revert?'); if (!rvOk) return;
25102510
this._applyPerfValues(this._perfSavedSnapshot);
25112511
this._updatePerfDirty();
25122512
};
25132513

2514-
defaultsBtn.onclick = () => {
2515-
if (!confirm('Reset all settings to defaults?')) return;
2514+
defaultsBtn.onclick = async () => {
2515+
const dfOk = window.gamepadConfirm ? await window.gamepadConfirm('Reset all settings to defaults?') : confirm('Reset to defaults?'); if (!dfOk) return;
25162516
const system = this.shadowRoot.getElementById('perfSystemSelect')?.value || 'n64';
25172517
const defaults = this._getPerfDefaults(system);
25182518
this._applyPerfValues(defaults);
@@ -2599,10 +2599,10 @@ <h3 style="font-size:16px;font-weight:600;color:#fff;margin:0;">Upload ROM</h3>
25992599

26002600
// Delete profile
26012601
grid.querySelectorAll('.perf-profile-delete').forEach(btn => {
2602-
btn.addEventListener('click', (e) => {
2602+
btn.addEventListener('click', async (e) => {
26032603
e.stopPropagation();
26042604
const idx = parseInt(btn.dataset.delIdx);
2605-
if (!confirm('Delete profile "' + profiles[idx]?.name + '"?')) return;
2605+
const dpOk = window.gamepadConfirm ? await window.gamepadConfirm('Delete profile "' + profiles[idx]?.name + '"?') : confirm('Delete profile?'); if (!dpOk) return;
26062606
profiles.splice(idx, 1);
26072607
this._savePerfProfiles(system, profiles);
26082608
this._renderPerfProfiles();
@@ -2856,13 +2856,13 @@ <h3 style="font-size:16px;font-weight:600;color:#fff;margin:0;">Upload ROM</h3>
28562856
this._updateNativePerfDirty();
28572857
} catch {}
28582858
};
2859-
if (revertBtn) revertBtn.onclick = () => {
2860-
if (!this._nativeSavedSnapshot || !confirm('Revert unsaved changes?')) return;
2859+
if (revertBtn) revertBtn.onclick = async () => {
2860+
if (!this._nativeSavedSnapshot) return; const nrvOk = window.gamepadConfirm ? await window.gamepadConfirm('Revert unsaved changes?') : confirm('Revert?'); if (!nrvOk) return;
28612861
this._applyNativePerfValues(this._nativeSavedSnapshot);
28622862
this._updateNativePerfDirty();
28632863
};
2864-
if (defaultsBtn) defaultsBtn.onclick = () => {
2865-
if (!confirm('Reset to defaults?')) return;
2864+
if (defaultsBtn) defaultsBtn.onclick = async () => {
2865+
const ndfOk = window.gamepadConfirm ? await window.gamepadConfirm('Reset to defaults?') : confirm('Reset to defaults?'); if (!ndfOk) return;
28662866
this._applyNativePerfValues(this._getNativePerfDefaults());
28672867
this._updateNativePerfDirty();
28682868
};

0 commit comments

Comments
 (0)