From 657e12463a0607bb4dd715bac370169c37f7b0aa Mon Sep 17 00:00:00 2001 From: NeKz Date: Wed, 17 Apr 2024 21:28:46 +0200 Subject: [PATCH] Add more rerender options --- src/server/app/assets/js/module.js | 20 ++++++---- src/server/app/components/RerenderModal.tsx | 44 ++++++++++++++++----- src/server/app/views/Video.tsx | 2 +- src/server/main.ts | 12 +++++- 4 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/server/app/assets/js/module.js b/src/server/app/assets/js/module.js index 5023c4f..f287864 100644 --- a/src/server/app/assets/js/module.js +++ b/src/server/app/assets/js/module.js @@ -283,6 +283,8 @@ const initRerenderModal = () => { const rerenderModalQueueButton = document.getElementById('rerender-modal-queue-button'); /** @type {HTMLInputElement} */ const rerenderModalRepairCheckbox = document.getElementById('rerender-modal-repair-checkbox'); + const rerenderModalSndRestartCheckbox = document.getElementById('rerender-modal-snd-restart-checkbox'); + const rerenderModalSkipCoopCheckbox = document.getElementById('rerender-modal-skip-coop-checkbox'); const tryRerenderButton = document.getElementById('video-try-rerender-button'); const rerenderButton = document.getElementById('video-rerender-button'); @@ -290,9 +292,9 @@ const initRerenderModal = () => { rerenderModal.classList.remove('hidden'); rerenderModal.classList.add('flex'); - if (rerenderModalRepairCheckbox) { - rerenderModalRepairCheckbox.checked = false; - } + if (rerenderModalRepairCheckbox) rerenderModalRepairCheckbox.checked = false; + if (rerenderModalSndRestartCheckbox) rerenderModalSndRestartCheckbox.checked = false; + if (rerenderModalSkipCoopCheckbox) rerenderModalSkipCoopCheckbox.checked = false; }; tryRerenderButton?.addEventListener('click', openModal); @@ -303,9 +305,9 @@ const initRerenderModal = () => { }); rerenderModalQueueButton?.addEventListener('click', () => { - if (rerenderModalRepairCheckbox) { - rerenderModalRepairCheckbox.setAttribute('disabled', ''); - } + if (rerenderModalRepairCheckbox) rerenderModalRepairCheckbox.setAttribute('disabled', ''); + if (rerenderModalSndRestartCheckbox) rerenderModalSndRestartCheckbox.setAttribute('disabled', ''); + if (rerenderModalSkipCoopCheckbox) rerenderModalSkipCoopCheckbox.setAttribute('disabled', ''); rerenderModalQueueButton.setAttribute('disabled', ''); rerenderModalQueueButton.textContent = 'Adding to queue...'; @@ -315,7 +317,11 @@ const initRerenderModal = () => { headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify({ demoRepair: rerenderModalRepairCheckbox?.checked ?? false }), + body: JSON.stringify({ + demoRepair: rerenderModalRepairCheckbox?.checked ?? false, + disableSndRestart: rerenderModalSndRestartCheckbox?.checked ?? false, + disableSkipCoopVideos: rerenderModalSkipCoopCheckbox?.checked ?? false, + }), }) .catch(console.error) .finally(() => location.replace(location.href)); diff --git a/src/server/app/components/RerenderModal.tsx b/src/server/app/components/RerenderModal.tsx index 83daddb..a5c542d 100644 --- a/src/server/app/components/RerenderModal.tsx +++ b/src/server/app/components/RerenderModal.tsx @@ -7,7 +7,7 @@ import * as React from 'react'; import { tw } from 'twind'; -const RerenderModal = ({ showDemoRepair }: { showDemoRepair: boolean }) => { +const RerenderModal = ({ isCoop }: { isCoop: boolean }) => { return (
{ - {showDemoRepair && ( -
-
+
+
+ + +
+
+ + +
+ {isCoop && ( +
-
- )} + )} +
- + ); }; diff --git a/src/server/main.ts b/src/server/main.ts index 82e9718..d8f42ef 100644 --- a/src/server/main.ts +++ b/src/server/main.ts @@ -744,7 +744,11 @@ apiV1 return Err(ctx, Status.BadRequest, 'Missing body.'); } - const { demoRepair } = await ctx.request.body({ type: 'json' }).value as { demoRepair: boolean }; + const { demoRepair, disableSndRestart, disableSkipCoopVideos } = await ctx.request.body({ type: 'json' }).value as { + demoRepair: boolean; + disableSndRestart: boolean; + disableSkipCoopVideos: boolean; + }; const [video] = await db.query< Pick< @@ -814,10 +818,14 @@ apiV1 : []), ]; - if (demoInfo.disableRenderSkipCoopVideos) { + if (demoInfo.disableRenderSkipCoopVideos || disableSkipCoopVideos) { renderOptions.push('sar_render_skip_coop_videos 0'); } + if (disableSndRestart) { + renderOptions.push('alias snd_restart ""'); + } + const requiredDemoFix = demoInfo.useFixedDemo ? FixedDemoStatus.Required : FixedDemoStatus.NotRequired; const demoMetadata = JSON.stringify(demoInfo.metadata);