This commit is contained in:
kakkokari-gtyih 2024-08-26 18:17:33 +09:00
parent 63b7795007
commit 535b34e371
1 changed files with 36 additions and 32 deletions

View File

@ -246,6 +246,38 @@ const canContinue = computed(() => {
} }
}); });
function findNextPage(type: TutorialPage['type']) {
const bodyPagesDefIndex = page.value - 1;
for (let i = bodyPagesDefIndex + 1; i < tutorialBodyPagesDef.length; i++) {
if (tutorialBodyPagesDef[i] == null) {
break;
}
if (tutorialBodyPagesDef[i].type === type) {
return i + 1; // 1
}
}
return MAX_PAGE;
}
function findPrevPage(type: TutorialPage['type']) {
const bodyPagesDefIndex = page.value - 1;
for (let i = bodyPagesDefIndex - 1; i >= 0; i--) {
if (tutorialBodyPagesDef[i] == null) {
break;
}
if (tutorialBodyPagesDef[i].type === type) {
return i + 1; // 1
}
}
return 0;
}
function next() { function next() {
if (areButtonsLocked.value) { if (areButtonsLocked.value) {
return; return;
@ -255,22 +287,8 @@ function next() {
const bodyPagesDefIndex = page.value - 1; const bodyPagesDefIndex = page.value - 1;
if (!props.withSetup && tutorialBodyPagesDef[bodyPagesDefIndex + 1].type === 'setup') { if (!props.withSetup && tutorialBodyPagesDef[bodyPagesDefIndex + 1].type !== 'tutorial') {
function findNextTutorialPage() { page.value = findNextPage('tutorial');
for (let i = bodyPagesDefIndex + 1; i < tutorialBodyPagesDef.length; i++) {
if (tutorialBodyPagesDef[i] == null) {
break;
}
if (tutorialBodyPagesDef[i].type === 'tutorial') {
return i + 1; // 1
}
}
return MAX_PAGE;
}
page.value = findNextTutorialPage();
} else { } else {
page.value = Math.min(page.value + 1, MAX_PAGE); page.value = Math.min(page.value + 1, MAX_PAGE);
} }
@ -287,22 +305,8 @@ function prev() {
const bodyPagesDefIndex = page.value - 1; const bodyPagesDefIndex = page.value - 1;
if (!props.withSetup && tutorialBodyPagesDef[bodyPagesDefIndex - 1].type === 'setup') { if (!props.withSetup && tutorialBodyPagesDef[bodyPagesDefIndex - 1].type !== 'tutorial') {
function findPrevTutorialPage() { page.value = findPrevPage('tutorial');
for (let i = bodyPagesDefIndex - 1; i >= 0; i--) {
if (tutorialBodyPagesDef[i] == null) {
break;
}
if (tutorialBodyPagesDef[i].type === 'tutorial') {
return i + 1; // 1
}
}
return 0;
}
page.value = findPrevTutorialPage();
} else { } else {
page.value = Math.max(page.value - 1, 0); page.value = Math.max(page.value - 1, 0);
} }