diff --git a/components/PromptEntry.tsx b/components/PromptEntry.tsx index 0c7b09b..e200e4e 100644 --- a/components/PromptEntry.tsx +++ b/components/PromptEntry.tsx @@ -1,23 +1,114 @@ import { NextComponentType } from 'next' +import { PlayingState } from '../types' interface PromptEntryProps { prompt: string index: number className: string + playingState: PlayingState } export default function PromptEntry({ prompt, index, className, -}: PromptEntryProps) { + playingState, +}: PromptEntryProps) { + + const getPromptCopy = (prompt: string) => { + switch (playingState) { + case PlayingState.UNINITIALIZED: + switch (index) { + case 0: + return prompt + case 1: + return prompt + case 2: + return prompt + case 3: + if (prompt == " " || prompt == "") { + return "..." + } + else { + return prompt + } + case 4: + if (prompt == " " || prompt == "") { + return "UP NEXT: Anything you want" + } + else { + return "UP NEXT: " + prompt + } + default: { + console.log("UNHANDLED default") + return prompt + } + } + case PlayingState.SAME_PROMPT: + switch (index) { + case 0: + return prompt + case 1: + return prompt + case 2: + return prompt + case 3: + if (prompt == " " || prompt == "") { + return "..." + } + else { + return prompt + } + case 4: + if (prompt == " " || prompt == "") { + return "UP NEXT: Anything you want" + } + else { + return "UP NEXT: " + prompt + } + default: { + console.log("UNHANDLED default") + return prompt + } + } + case PlayingState.TRANSITION: + switch (index) { + case 0: + return prompt + case 1: + return prompt + case 2: + return prompt + case 3: + return prompt + case 4: + if (prompt == " " || prompt == "") { + return "..." + } + else { + return prompt + } + case 5: + if (prompt == " " || prompt == "") { + return "UP NEXT: Anything you want" + } + else { + return "UP NEXT: " + prompt + } + default: { + console.log("UNHANDLED default") + return prompt + } + } + } + } + return ( - <> -
- {index + " " + prompt} - {/* {prompt == "" ? index == 5 ? "UP NEXT: Anything you want" + prompt : "..." : index == 5 ? "UP NEXT: " + prompt : prompt} */} -
- > + <> ++ {getPromptCopy(prompt)} +
+ > ) - } +} diff --git a/components/PromptPanel.tsx b/components/PromptPanel.tsx index e617c3f..01fa1b5 100644 --- a/components/PromptPanel.tsx +++ b/components/PromptPanel.tsx @@ -1,33 +1,30 @@ import PromptEntry from "./PromptEntry"; -import { InferenceResult, PromptInput } from "../types"; +import { AppState, PlayingState, InferenceResult, PromptInput } from "../types"; import { useRef } from "react"; interface PromptPanelProps { prompts: PromptInput[]; inferenceResults: InferenceResult[]; nowPlayingResult: InferenceResult; + appState: AppState; changePrompt: (prompt: string, index: number) => void; } -enum PlayingState { - UNINITIALIZED = "UNINITIALIZED", - SAME_PROMPT = "SAME_PROMPT", - TRANSITION = "TRANSITION", -} - export default function PromptPanel({ prompts, inferenceResults, nowPlayingResult, + appState, changePrompt, }: PromptPanelProps) { const inputPrompt = useRef(null); + var playingState: PlayingState + const getDisplayPrompts = () => { var displayPrompts = []; - var playingState: PlayingState if (nowPlayingResult == null) { playingState = PlayingState.UNINITIALIZED } else if (nowPlayingResult.input.start.prompt == nowPlayingResult.input.end.prompt) { @@ -53,7 +50,7 @@ export default function PromptPanel({ // add the most recent end prompts to the displayPrompts lastPlayedResultsAlphaTransition.forEach((result) => { - displayPrompts.push({ prompt: result.input.end.prompt}); + displayPrompts.push({ prompt: result.input.end.prompt }); }); // Handle the case where there are less than 4 played results (i.e. the initial state) @@ -76,7 +73,7 @@ export default function PromptPanel({ lastPromptsCopy[index].transitionCounter = null; } }); - + // add the prompts to the displayPrompts lastPromptsCopy.forEach((p) => { displayPrompts.push(p); @@ -90,17 +87,68 @@ export default function PromptPanel({ return displayPrompts; } + const getPromptEntryClassName = (index: number) => { + switch (playingState) { + case PlayingState.UNINITIALIZED: + console.log("promptEntryClassNames_5_0") + return promptEntryClassNames_5_0[index]; + case PlayingState.SAME_PROMPT: + if (appState != AppState.TRANSITION) { + console.log("promptEntryClassNames_5_0") + return promptEntryClassNames_5_0[index]; + + } else { + switch (nowPlayingResult.input.alpha) { + case 0: + console.log("promptEntryClassNames_5_0") + return promptEntryClassNames_5_0[index]; + case 0.25: + console.log("UNHANDLED promptEntryClassNames_5_25") // this is never reached currently + case 0.5: + console.log("promptEntryClassNames_5_50") + return promptEntryClassNames_5_50[index]; + case 0.75: + console.log("promptEntryClassNames_5_75") + return promptEntryClassNames_5_75[index]; + case 1: + console.log("promptEntryClassNames_5_1") + return promptEntryClassNames_5_1[index]; + } + } + case PlayingState.TRANSITION: + switch (nowPlayingResult.input.alpha) { + case 0: + console.log("UNHANDLED promptEntryClassNames_6_0") // this is never reached currently + case 0.25: + console.log("promptEntryClassNames_6_25") + return promptEntryClassNames_6_25[index]; + case 0.5: + console.log("promptEntryClassNames_6_50") + return promptEntryClassNames_6_50[index]; + case 0.75: + console.log("promptEntryClassNames_6_75") + return promptEntryClassNames_6_75[index]; + case 1: + console.log("promptEntryClassNames_6_1") + return promptEntryClassNames_6_1[index]; + } + default: + console.log("UNHANDLED playingState: " + playingState) + } + } + return ( <>