Skip to content

Commit

Permalink
Add more rerender options
Browse files Browse the repository at this point in the history
  • Loading branch information
NeKzor committed Apr 17, 2024
1 parent 1831f8b commit 657e124
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 19 deletions.
20 changes: 13 additions & 7 deletions src/server/app/assets/js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,18 @@ 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');

const openModal = () => {
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);
Expand All @@ -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...';
Expand All @@ -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));
Expand Down
44 changes: 35 additions & 9 deletions src/server/app/components/RerenderModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import * as React from 'react';
import { tw } from 'twind';

const RerenderModal = ({ showDemoRepair }: { showDemoRepair: boolean }) => {
const RerenderModal = ({ isCoop }: { isCoop: boolean }) => {
return (
<div
id='rerender-modal'
Expand Down Expand Up @@ -44,23 +44,49 @@ const RerenderModal = ({ showDemoRepair }: { showDemoRepair: boolean }) => {
<label className={tw`block mb-2 text-sm font-medium text-gray-900 dark:text-white`}>
Rerender
</label>
{showDemoRepair && (
<div className={tw`flex items-center mt-2`}>
<div className={tw`flex items-center mr-4`}>
<div className={tw`mt-2`}>
<div className={tw`flex items-center mr-4 mb-2 mt-2`}>
<input
id='rerender-modal-repair-checkbox'
type='checkbox'
className={tw`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600`}
/>
<label
htmlFor='rerender-modal-repair-checkbox'
className={tw`ml-2 text-sm font-medium text-gray-900 dark:text-gray-300`}
>
Run Demo Repair (experimental)
</label>
</div>
<div className={tw`flex items-center mr-4 mb-2`}>
<input
id='rerender-modal-snd-restart-checkbox'
type='checkbox'
className={tw`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600`}
/>
<label
htmlFor='rerender-modal-snd-restart-checkbox'
className={tw`ml-2 text-sm font-medium text-gray-900 dark:text-gray-300`}
>
Disable snd_restart
</label>
</div>
{isCoop && (
<div className={tw`flex items-center mr-4 mb-2`}>
<input
id='rerender-modal-repair-checkbox'
id='rerender-modal-skip-coop-checkbox'
type='checkbox'
className={tw`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600`}
/>
<label
htmlFor='rerender-modal-repair-checkbox'
htmlFor='rerender-modal-skip-coop-checkbox'
className={tw`ml-2 text-sm font-medium text-gray-900 dark:text-gray-300`}
>
Run Demo Repair (experimental)
Disable sar_render_skip_coop_videos
</label>
</div>
</div>
)}
)}
</div>
</div>
<button
id='rerender-modal-queue-button'
Expand Down
2 changes: 1 addition & 1 deletion src/server/app/views/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ export const VideoView = () => {
</div>
</div>
<ShareModal />
<RerenderModal showDemoRepair />
<RerenderModal isCoop={data.type === MapType.Cooperative || data.type === MapType.WorkshopCooperative} />
</>
);
};
12 changes: 10 additions & 2 deletions src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 657e124

Please sign in to comment.