Skip to content

Commit

Permalink
add more quests
Browse files Browse the repository at this point in the history
  • Loading branch information
Entkenntnis committed Dec 26, 2022
1 parent 8e95803 commit 1fc09a5
Show file tree
Hide file tree
Showing 15 changed files with 1,439 additions and 165 deletions.
4 changes: 2 additions & 2 deletions components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export function App() {
return (
<>
<Head>
<title>Robot Karol Online</title>
<title>{core.ws.ui.isEditor ? 'Editor ' : 'Robot Karol Online'}</title>
<meta
name="description"
content="Der zeitlose Klassiker für den spielerischen Einstieg in die Programmierung."
/>
</Head>
<div className="w-full h-full min-w-[900px] overflow-hidden">
<div className="w-full h-full min-w-[900px] overflow-auto">
{core.ws.ui.clientInitDone &&
(core.ws.ui.showQuestOverview ? <Overview /> : <Quest />)}
</div>
Expand Down
6 changes: 3 additions & 3 deletions components/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function Overview() {
const core = useCore()

return (
<div className="bg-yellow-200 h-full flex flex-col relative">
<div className="bg-yellow-200 flex flex-col relative min-h-screen">
<div className="flex justify-center">
<div
className={clsx(
Expand Down Expand Up @@ -86,7 +86,7 @@ export function Overview() {
</button>
</div>
)}
<div className="text-center mb-2">
<div className="text-center mb-2 mt-10">
<button
className="hover:underline"
onClick={() => {
Expand Down Expand Up @@ -138,7 +138,7 @@ export function Overview() {

function renderQuest(index: number, i: number) {
if (index == -1) {
return <div className="basis-full h-1" key={`spacer_${i}`}></div>
return <div className="basis-full h-8" key={`spacer_${i}`}></div>
}

// check for deps, empty deps -> always visible
Expand Down
279 changes: 140 additions & 139 deletions components/Tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,149 +54,150 @@ export function Tasks() {

return (
<div className="w-full h-full flex flex-col">
<div className="p-4 px-7 flex-shrink-0 flex-grow-0 bg-yellow-100 relative max-h-[40%] overflow-auto">
{core.ws.ui.isEditor ? (
<QuestEditor />
) : (
<>
<h1 className="mb-2 text-xl font-bold mt-1">
{core.ws.quest.title}
{core.ws.ui.isAlreadyCompleted && core.ws.quest.id < 0 && (
<span className="text-base font-normal text-green-600 ml-4">
<FaIcon icon={faCheck} /> abgeschlossen
</span>
)}
</h1>
{!core.ws.ui.isImportedProject &&
!core.ws.ui.editorLoading &&
core.ws.quest.id >= 0 && (
<div className="mb-4">
<button
className={clsx(
'text-blue-500 hover:text-blue-600 hover:underline'
<div className="flex-auto overflow-auto bg-gray-100" ref={taskContainer}>
<div>
<div className="p-4 px-7 bg-yellow-100">
{core.ws.ui.isEditor ? (
<QuestEditor />
) : (
<>
<h1 className="mb-2 text-xl font-bold mt-1">
{core.ws.quest.title}
{core.ws.ui.isAlreadyCompleted && core.ws.quest.id < 0 && (
<span className="text-base font-normal text-green-600 ml-4">
<FaIcon icon={faCheck} /> abgeschlossen
</span>
)}
</h1>
{!core.ws.ui.isImportedProject &&
!core.ws.ui.editorLoading &&
core.ws.quest.id >= 0 && (
<div className="mb-4">
<button
className={clsx(
'text-blue-500 hover:text-blue-600 hover:underline'
)}
onClick={() => {
storeQuestToSession(core)
showQuestOverview(core)
}}
>
zurück
</button>
</div>
)}
<div>{processMiniMarkdown(core.ws.quest.description)}</div>
</>
)}
</div>
<div className="flex-grow flex-shrink overflow-y-auto pb-6">
{core.ws.quest.tasks.map((task, index) => (
<div
className={clsx(
'm-3 rounded-xl bg-white flex justify-between',
!core.ws.ui.isEditor && 'cursor-pointer hover:bg-gray-50'
)}
key={index}
tabIndex={0}
onClick={() => {
setTaskScroll(core, taskContainer.current?.scrollTop ?? -1)
if (core.ws.ui.isEditor) return
openTask(core, index)
}}
>
<div className="ml-4 mt-6">
<h2 className="text-lg font-bold">
{core.ws.ui.isEditor ? (
<input
value={task.title}
className="bg-gray-100"
onChange={(e) => {
setTaskTitle(core, index, e.target.value)
}}
/>
) : (
task.title
)}
onClick={() => {
storeQuestToSession(core)
showQuestOverview(core)
}}
>
zurück
</button>
</h2>
{core.ws.ui.isEditor && (
<>
<p className="mt-4">
<button
className="rounded px-2 py-0.5 bg-gray-100 hover:bg-gray-200"
onClick={() => {
openTask(core, index)
}}
>
<FaIcon icon={faPlay} className="mr-2" />
Testen
</button>
<button
className="ml-3 rounded px-2 py-0.5 bg-blue-100 hover:bg-blue-200"
onClick={() => {
editWorld(core, index)
}}
>
<FaIcon icon={faPencil} className="mr-2" />
Welt bearbeiten
</button>
</p>
<p className="mt-20 text-sm text-gray-700">
<button
className="hover:text-black disabled:text-gray-200"
disabled={index == 0}
onClick={() => {
moveTaskUp(core, index)
}}
>
<FaIcon icon={faArrowUp} /> hoch
</button>
<button
className="hover:text-black disabled:text-gray-200 ml-5"
disabled={index + 1 == core.ws.quest.tasks.length}
onClick={() => {
moveTaskDown(core, index)
}}
>
<FaIcon icon={faArrowDown} /> runter
</button>
<button
className="hover:text-red-600 ml-5"
onClick={() => {
deleteTask(core, index)
}}
>
<FaIcon
icon={faTrashCan}
className="text-gray-500 mr-0.5"
/>{' '}
Auftrag löschen
</button>
</p>
</>
)}
</div>
)}
<div>{processMiniMarkdown(core.ws.quest.description)}</div>
</>
)}
</div>
<div
className="flex-grow flex-shrink overflow-y-auto bg-gray-100"
ref={taskContainer}
>
{core.ws.quest.tasks.map((task, index) => (
<div
className={clsx(
'm-3 rounded-xl bg-white flex justify-between',
!core.ws.ui.isEditor && 'cursor-pointer hover:bg-gray-50'
)}
key={index}
tabIndex={0}
onClick={() => {
setTaskScroll(core, taskContainer.current?.scrollTop ?? -1)
if (core.ws.ui.isEditor) return
openTask(core, index)
}}
>
<div className="ml-4 mt-6">
<h2 className="text-lg font-bold">
{core.ws.ui.isEditor ? (
<input
value={task.title}
className="bg-gray-100"
onChange={(e) => {
setTaskTitle(core, index, e.target.value)
}}
<div
className="h-48 mb-6 mr-8 cursor-pointer"
onClick={() => {
editWorld(core, index)
}}
>
<View
world={task.start}
preview={
task.target === null
? undefined
: { track: [], world: task.target }
}
hideKarol={false}
wireframe={false}
className="h-full w-full object-contain"
/>
) : (
task.title
)}
</h2>
{core.ws.ui.isEditor && (
<>
<p className="mt-4">
<button
className="rounded px-2 py-0.5 bg-gray-100 hover:bg-gray-200"
onClick={() => {
openTask(core, index)
}}
>
<FaIcon icon={faPlay} className="mr-2" />
Testen
</button>
<button
className="ml-3 rounded px-2 py-0.5 bg-blue-100 hover:bg-blue-200"
onClick={() => {
editWorld(core, index)
}}
>
<FaIcon icon={faPencil} className="mr-2" />
Welt bearbeiten
</button>
</p>
<p className="mt-20 text-sm text-gray-700">
<button
className="hover:text-black disabled:text-gray-200"
disabled={index == 0}
onClick={() => {
moveTaskUp(core, index)
}}
>
<FaIcon icon={faArrowUp} /> hoch
</button>
<button
className="hover:text-black disabled:text-gray-200 ml-5"
disabled={index + 1 == core.ws.quest.tasks.length}
onClick={() => {
moveTaskDown(core, index)
}}
>
<FaIcon icon={faArrowDown} /> runter
</button>
<button
className="hover:text-red-600 ml-5"
onClick={() => {
deleteTask(core, index)
}}
>
<FaIcon
icon={faTrashCan}
className="text-gray-500 mr-0.5"
/>{' '}
Auftrag löschen
</button>
</p>
</>
)}
</div>
<div
className="h-48 mb-6 mr-8 cursor-pointer"
onClick={() => {
editWorld(core, index)
}}
>
<View
world={task.start}
preview={
task.target === null
? undefined
: { track: [], world: task.target }
}
hideKarol={false}
wireframe={false}
className="h-full w-full object-contain"
/>
</div>
</div>
</div>
))}
</div>
))}
</div>
</div>
<div className="h-10 flex-shrink-0 flex-grow-0 flex bg-gray-100 py-1">
<div className="flex justify-center relative items-center flex-grow">
Expand Down
2 changes: 1 addition & 1 deletion components/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export function View({
ctx.restore()
}
if (world.marks[y][x] && preview && !preview?.world.marks[y][x]) {
const p = to2d(x, y, preview.world.bricks[y][x])
const p = to2d(x, y, world.bricks[y][x])
ctx.save()
ctx.globalAlpha = 1
ctx.drawImage(marke_weg, p.x - 15, p.y - 16)
Expand Down
5 changes: 5 additions & 0 deletions components/WorldEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ export function WorldEditor() {
return
}
}}
onClick={() => {
if (core.ws.editor.showWorldPreview) {
switchCurrentlyEditedWorld(core, 'start')
}
}}
ref={handlerDiv}
>
{core.ws.editor.showWorldPreview ? (
Expand Down
2 changes: 1 addition & 1 deletion lib/data/overview.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const overviewData = [
1, 2, 3, 4, 5, -1, 6, 7, 10, 11, 14, -1, 8, 9, 12, -1, 15, 13,
1, 2, 3, 4, 5, -1, 6, 7, 8, 10, 11, 14, -1, 9, 12, -1, 13, 15,
]
Loading

0 comments on commit 1fc09a5

Please sign in to comment.