Skip to content

Commit 7bf5cbb

Browse files
committed
initial version of intro dialog
1 parent 0228bf3 commit 7bf5cbb

File tree

5 files changed

+80
-12
lines changed

5 files changed

+80
-12
lines changed

index.html

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,30 @@
1111
</head>
1212

1313
<body>
14+
<dialog id="intro-dialog">
15+
<img src="title.png" alt="Datapack Toolkit" />
16+
<p>An easy-to-use Minecraft worldgen datapack configuration tool!</p>
17+
<p>Early in development, currently supporting:</p>
18+
19+
<ul>
20+
<li>Custom datapack configuration options</li>
21+
</ul>
22+
<p>Planned to support:</p>
23+
<ul>
24+
<li>Picking biome definition providers</li>
25+
<li>Editing structure set placement</li>
26+
</ul>
27+
<div class="button-container">
28+
<button type="button">Ok! Let me configure</button>
29+
</div>
30+
</div>
31+
</dialog>
32+
1433
<div class="header">
1534
<div>
1635
<p>Datapack Toolkit (indev)</p>
1736
</div>
37+
1838
<div class="header-middle">
1939
<p>
2040
<a id="config-screen-select">
@@ -28,6 +48,7 @@
2848
</a>
2949
</p>
3050
</div>
51+
3152
<div>
3253
<p>
3354
<a href="https://github.com/everloste/DatapackToolkit/wiki">
@@ -62,10 +83,7 @@
6283
</p>
6384
</div>
6485
</div>
65-
<!-- <p>
66-
Datapack Toolkit is a tool that streamlines custom worldgen configuration.
67-
<a href="https://github.com/everloste/DatapackToolkit/wiki">Make your datapack compatible.</a>
68-
</p> -->
86+
6987
<div class="work_area">
7088
<!---------- LEFT COLUMN ---------->
7189
<div id="left-col">

public/title.png

856 Bytes
Loading

src/main.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DatapackModifierInstance } from "./datapack_changes";
33
import { type DatapackStoreEvents, datapackStore } from "./datapackStore";
44
import { getExportSettings } from "./page_interactions/settings";
55
import { getStructureSets } from "./structureSet";
6+
import { showIntroIfNotShown } from "./page_interactions/introDialog";
67

78
const fileUploadElement = document.getElementById("input")!;
89
fileUploadElement.addEventListener("change", onFileUploaded, { passive: true });
@@ -93,7 +94,6 @@ function sanitizeHtml(unsafe: string): string {
9394
return div.innerHTML;
9495
}
9596

96-
9797
////////// EXPORT SETTINGS //////////
9898
const collapsibles = document.getElementsByClassName("collapsible-button");
9999

@@ -103,7 +103,8 @@ for (const collapsible of collapsibles) {
103103

104104
var content = collapsible.nextElementSibling;
105105
if (content != null) {
106-
if ((content as HTMLDivElement).style.display === "block") (content as HTMLDivElement).style.display = "none";
106+
if ((content as HTMLDivElement).style.display === "block")
107+
(content as HTMLDivElement).style.display = "none";
107108
else (content as HTMLDivElement).style.display = "block";
108109
}
109110
});
@@ -123,7 +124,9 @@ function exportButtonClicked() {
123124
datapack.instancedConfig?.apply();
124125
});
125126

126-
DatapackModifierInstance.applyChanges(datapackStore.getAll(), export_settings).then(
127-
() => {document.getElementById("progress-indicator")!.hidden = true;}
128-
);
129-
}
127+
DatapackModifierInstance.applyChanges(datapackStore.getAll(), export_settings).then(() => {
128+
document.getElementById("progress-indicator")!.hidden = true;
129+
});
130+
}
131+
132+
showIntroIfNotShown();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export function showIntroIfNotShown() {
2+
const currentIntroVersion = 0;
3+
4+
const introDialog = document.getElementById("intro-dialog") as HTMLDialogElement;
5+
const closeIntroButton = introDialog.querySelector("button") as HTMLButtonElement;
6+
7+
const lastShownVersion = Number.parseInt(localStorage.getItem("dialogVersion") || "-1");
8+
9+
if (lastShownVersion >= currentIntroVersion) {
10+
console.info(`Intro dialog already shown (version ${lastShownVersion}), skipping.`);
11+
return;
12+
}
13+
14+
closeIntroButton.addEventListener("click", () => {
15+
localStorage.setItem("dialogVersion", currentIntroVersion.toString());
16+
introDialog.close();
17+
});
18+
19+
introDialog.showModal();
20+
}

style.css

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ button,
6060
color: inherit;
6161
background-color: var(--background-above);
6262

63-
padding-bottom: 0.5em;
64-
padding-top: 0.5em;
63+
padding: 0.5rem 1rem;
6564

6665
transition: all var(--ease-out-quint) 0.25s;
6766

@@ -80,6 +79,34 @@ button,
8079
}
8180
}
8281

82+
dialog {
83+
color: inherit;
84+
background: var(--background);
85+
border: var(--border-width) solid var(--background-above);
86+
87+
max-width: 30rem;
88+
89+
h1 {
90+
margin: 0;
91+
}
92+
93+
img {
94+
width: 100%;
95+
image-rendering: pixelated;
96+
margin: 0 auto;
97+
}
98+
99+
.button-container {
100+
width: 100%;
101+
display: flex;
102+
justify-content: flex-end;
103+
}
104+
105+
&::backdrop {
106+
backdrop-filter: blur(5px) brightness(0.7);
107+
}
108+
}
109+
83110
input[type="range"] {
84111
background: transparent;
85112
}

0 commit comments

Comments
 (0)