Skip to content

Commit f81b6a8

Browse files
committed
🚧 Add export page to blueprint settings
1 parent f360d67 commit f81b6a8

File tree

6 files changed

+98
-71
lines changed

6 files changed

+98
-71
lines changed

src/svelte/blueprintSettings/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { makeNotValueable, makeValuable, Valuable } from '../../util/stores'
1010
import { SvelteSidebarDialog } from '../../util/svelteDialog'
1111
import { translate } from '../../util/translation'
1212
import Datapack from './pages/datapack.svelte'
13+
import Export from './pages/export.svelte'
1314
import General from './pages/general.svelte'
1415
import Plugin from './pages/plugin.svelte'
1516
import Resourcepack from './pages/resourcepack.svelte'
@@ -48,6 +49,15 @@ export function openBlueprintSettingsDialog() {
4849
component: General,
4950
props: { settings },
5051
},
52+
export: {
53+
icon: 'save',
54+
label: 'Export',
55+
component: Export,
56+
props: { settings },
57+
condition() {
58+
return settings.environment.get() === 'vanilla'
59+
},
60+
},
5161
datapack: {
5262
icon: 'folder',
5363
label: 'Data Pack',
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<script lang="ts">
2+
import { type ValuableBlueprintSettings } from '../'
3+
import { defaultValues } from '../../../blueprintSettings'
4+
import { type MinecraftVersion } from '../../../systems/datapackCompiler/mcbFiles'
5+
import {
6+
containsInvalidScoreboardTagCharacters,
7+
createTagPrefixFromBlueprintID,
8+
} from '../../../util/minecraftUtil'
9+
import Checkbox from '../../components/sidebarDialogItems/checkbox.svelte'
10+
import LineEdit from '../../components/sidebarDialogItems/lineEdit.svelte'
11+
import OptionSelect from '../../components/sidebarDialogItems/optionSelect.svelte'
12+
13+
export let settings: ValuableBlueprintSettings
14+
15+
const blueprintID = settings.id
16+
const tagPrefix = settings.tag_prefix
17+
const autoGenerateTagPrefix = settings.auto_generate_tag_prefix
18+
19+
// Defining this here to get TS errors when the values are not updated.
20+
const versions: Record<MinecraftVersion, MinecraftVersion> = {
21+
'1.21.4': '1.21.4',
22+
'1.21.2': '1.21.2',
23+
'1.21.0': '1.21.0',
24+
'1.20.5': '1.20.5',
25+
'1.20.4': '1.20.4',
26+
}
27+
28+
$: if ($autoGenerateTagPrefix) {
29+
const tag = createTagPrefixFromBlueprintID($blueprintID)
30+
if (tag) {
31+
$tagPrefix = tag
32+
}
33+
}
34+
35+
const tagPrefexChecker: DialogItemValueChecker<string> = value => {
36+
if (value === '') {
37+
return {
38+
type: 'error',
39+
message: 'The Tag Prefix cannot be empty!',
40+
}
41+
} else if (containsInvalidScoreboardTagCharacters(value)) {
42+
return {
43+
type: 'error',
44+
message: 'The Tag Prefix contains invalid characters!',
45+
}
46+
}
47+
48+
return { type: 'success' }
49+
}
50+
</script>
51+
52+
<OptionSelect
53+
label="Target Minecraft Version"
54+
description="Choose the version of Minecraft you are exporting this project for.<br/>If your exact version is not listed, choose the closest version before the one you are using."
55+
selected={settings.target_minecraft_version}
56+
options={versions}
57+
required
58+
/>
59+
60+
<LineEdit
61+
label="Tag Prefix"
62+
description="Choose a prefix for the tags used in your project."
63+
value={settings.tag_prefix}
64+
defaultValue={defaultValues.tag_prefix}
65+
required
66+
disabled={$autoGenerateTagPrefix}
67+
valueChecker={tagPrefexChecker}
68+
/>
69+
70+
<Checkbox
71+
label="Auto-Generate Tag Prefix"
72+
description="Automatically generate a tag prefix based on the blueprint ID."
73+
checked={settings.auto_generate_tag_prefix}
74+
/>

src/svelte/blueprintSettings/pages/general.svelte

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,7 @@
1919
2020
export let settings: ValuableBlueprintSettings
2121
22-
const blueprintID = settings.id
23-
const tagPrefix = settings.tag_prefix
24-
const autoGenerateTagPrefix = settings.auto_generate_tag_prefix
25-
26-
// Defining this here to get TS errors when the values are not updated.
27-
const versions: Record<MinecraftVersion, MinecraftVersion> = {
28-
'1.20.4': '1.20.4',
29-
'1.20.5': '1.20.5',
30-
'1.21.0': '1.21.0',
31-
'1.21.2': '1.21.2',
32-
'1.21.4': '1.21.4',
33-
}
34-
35-
$: if ($autoGenerateTagPrefix) {
36-
const tag = createTagPrefixFromBlueprintID($blueprintID)
37-
if (tag) {
38-
$tagPrefix = tag
39-
}
40-
}
41-
42-
const blueprintIDChecker: DialogItemValueChecker<string> = (value: string) => {
22+
const blueprintIDChecker: DialogItemValueChecker<string> = value => {
4323
if (value === '') {
4424
return {
4525
type: 'error',
@@ -77,22 +57,6 @@
7757
return { type: 'success' }
7858
}
7959
80-
const tagPrefexChecker: DialogItemValueChecker<string> = value => {
81-
if (value === '') {
82-
return {
83-
type: 'error',
84-
message: 'The Tag Prefix cannot be empty!',
85-
}
86-
} else if (containsInvalidScoreboardTagCharacters(value)) {
87-
return {
88-
type: 'error',
89-
message: 'The Tag Prefix contains invalid characters!',
90-
}
91-
}
92-
93-
return { type: 'success' }
94-
}
95-
9660
const textureSizeChecker: DialogItemValueChecker<{ x: number; y: number }> = value => {
9761
const x = Number(value.x)
9862
const y = Number(value.y)
@@ -171,22 +135,6 @@
171135
valueChecker={blueprintIDChecker}
172136
/>
173137

174-
<LineEdit
175-
label="Tag Prefix"
176-
description="Choose a prefix for the tags used in your project."
177-
value={settings.tag_prefix}
178-
defaultValue={defaultValues.tag_prefix}
179-
required
180-
disabled={$autoGenerateTagPrefix}
181-
valueChecker={tagPrefexChecker}
182-
/>
183-
184-
<Checkbox
185-
label="Auto-Generate Tag Prefix"
186-
description="Automatically generate a tag prefix based on the blueprint ID."
187-
checked={settings.auto_generate_tag_prefix}
188-
/>
189-
190138
<Vector2d
191139
label="Texture Size"
192140
description="The size of the largest texture used for the blueprint."
@@ -201,11 +149,3 @@
201149
required
202150
valueChecker={textureSizeChecker}
203151
/>
204-
205-
<OptionSelect
206-
label="Target Minecraft Version"
207-
description="Choose the version of Minecraft you are exporting this project for.<br/>If your exact version is not listed, choose the closest version before the one you are using."
208-
selected={settings.target_minecraft_version}
209-
options={versions}
210-
required
211-
/>
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
type DialogItemValueChecker<Value> =
2-
| ((
3-
value: Value
4-
) =>
5-
| { type: 'success' }
6-
| { type: 'warning'; message: string }
7-
| { type: 'error'; message: string })
2+
| ((value: Value) => {
3+
type: 'success' | 'warning' | 'error'
4+
message?: string
5+
})
86
| undefined
97

108
type CollectionItem = { icon?: string; name: string; value: string }

src/svelte/components/sidebarDialogItems/boxSelect.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
transform: rotate(345deg);
8080
pointer-events: none;
8181
user-select: none;
82+
/* prettier-ignore */
83+
filter:
84+
drop-shadow(-2px 0px 1px var(--color-dark))
85+
drop-shadow(2px 0px 1px var(--color-dark))
86+
drop-shadow(0px -2px 0px var(--color-dark))
87+
drop-shadow(0px 2px 1px var(--color-dark));
8288
}
8389
.option-description {
8490
font-size: 0.9em;

src/systems/cleaner.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { isFunctionTagPath } from '../util/fileUtil'
22
import { IFunctionTag, parseDataPackPath } from '../util/minecraftUtil'
3-
import { DataPackAJMeta } from './datapackCompiler'
3+
import { AJMeta } from './ajmeta'
44
import { getExportPaths } from './exporter'
5-
import { ResourcePackAJMeta } from './resourcepackCompiler/global'
65
import { replacePathPart } from './util'
76

87
export async function cleanupExportedFiles() {
@@ -17,7 +16,7 @@ export async function cleanupExportedFiles() {
1716

1817
if (aj.resource_pack_export_mode === 'raw') {
1918
const assetsMetaPath = PathModule.join(resourcePackFolder, 'assets.ajmeta')
20-
const assetsMeta = new ResourcePackAJMeta(
19+
const assetsMeta = new AJMeta(
2120
assetsMetaPath,
2221
aj.export_namespace,
2322
Project!.last_used_export_namespace,
@@ -69,7 +68,7 @@ export async function cleanupExportedFiles() {
6968

7069
if (aj.data_pack_export_mode === 'raw') {
7170
const dataMetaPath = PathModule.join(dataPackFolder, 'data.ajmeta')
72-
const dataMeta = new DataPackAJMeta(
71+
const dataMeta = new AJMeta(
7372
dataMetaPath,
7473
aj.export_namespace,
7574
Project!.last_used_export_namespace,

0 commit comments

Comments
 (0)