|
1 | | -import { mount } from 'svelte' |
2 | | -import { observable } from 'svelte-observable-store' |
3 | | -import { SvelteDialog } from 'svelte-patching-tools/blockbench' |
4 | | -import { PACKAGE } from '../../constants' |
| 1 | +import { SvelteDialogSidebar } from 'svelte-patching-tools/blockbench' |
5 | 2 | import { updateRotationConstraints } from '../../formats/blueprint' |
6 | | -import { type ExportMode } from '../../formats/blueprint/settings' |
| 3 | +import { |
| 4 | + EXPORT, |
| 5 | + EXPORT_DEBUG, |
| 6 | + OPEN_ABOUT, |
| 7 | + OPEN_DOCUMENTATION, |
| 8 | +} from '../../interface/animatedJavaBarItem' |
7 | 9 | import { updateAllCubeOutlines } from '../../mods/cube' |
8 | | -import { SUPPORTED_MINECRAFT_VERSIONS } from '../../systems/global' |
9 | | -import { localize as translate } from '../../util/lang' |
10 | | -import { openBlueprintSettingsv2 } from '../blueprintSettingsv2/blueprintSettings' |
11 | | -import BlueprintSettings from './blueprintSettings.svelte' |
12 | | -import BlueprintSettingsAds from './blueprintSettingsAds.svelte' |
| 10 | +import { createScopedTranslator } from '../../util/lang' |
| 11 | +import Footer from './footer.svelte' |
| 12 | +import Datapack from './pages/datapack.svelte' |
| 13 | +import EventFunctions from './pages/eventFunctions.svelte' |
| 14 | +import General from './pages/general.svelte' |
| 15 | +import Misc from './pages/misc.svelte' |
| 16 | +import Resourcepack from './pages/resourcepack.svelte' |
13 | 17 |
|
14 | | -function getSettings() { |
15 | | - return { |
16 | | - blueprintName: observable(Project!.name), |
17 | | - textureSizeX: observable(Project!.texture_width), |
18 | | - textureSizeY: observable(Project!.texture_height), |
19 | | - showRenderBox: observable(Project!.animated_java.show_render_box), |
20 | | - autoRenderBox: observable(Project!.animated_java.auto_render_box), |
21 | | - renderBoxX: observable(Project!.animated_java.render_box[0]), |
22 | | - renderBoxY: observable(Project!.animated_java.render_box[1]), |
23 | | - // Export Settings |
24 | | - enablePluginMode: observable(Project!.animated_java.enable_plugin_mode), |
25 | | - exportNamespace: observable(Project!.animated_java.export_namespace), |
26 | | - resourcePackExportMode: observable( |
27 | | - Project!.animated_java.resource_pack_export_mode as string |
28 | | - ), |
29 | | - dataPackExportMode: observable(Project!.animated_java.data_pack_export_mode as string), |
30 | | - targetMinecraftVersion: observable( |
31 | | - Project!.animated_java.target_minecraft_version as string |
32 | | - ), |
33 | | - // Resource Pack Settings |
34 | | - displayItem: observable(Project!.animated_java.display_item), |
35 | | - customModelDataOffset: observable(Project!.animated_java.custom_model_data_offset), |
36 | | - enableAdvancedResourcePackSettings: observable( |
37 | | - Project!.animated_java.enable_advanced_resource_pack_settings |
38 | | - ), |
39 | | - resourcePack: observable(Project!.animated_java.resource_pack), |
40 | | - // Data Pack Settings |
41 | | - enableAdvancedDataPackSettings: observable( |
42 | | - Project!.animated_java.enable_advanced_data_pack_settings |
43 | | - ), |
44 | | - dataPack: observable(Project!.animated_java.data_pack), |
45 | | - onSummonFunction: observable(Project!.animated_java.on_summon_function), |
46 | | - onRemoveFunction: observable(Project!.animated_java.on_remove_function), |
47 | | - onPreTickFunction: observable(Project!.animated_java.on_pre_tick_function), |
48 | | - onPostTickFunction: observable(Project!.animated_java.on_post_tick_function), |
49 | | - interpolationDuration: observable(Project!.animated_java.interpolation_duration), |
50 | | - teleportationDuration: observable(Project!.animated_java.teleportation_duration), |
51 | | - autoUpdateRigOrientation: observable(Project!.animated_java.auto_update_rig_orientation), |
52 | | - useStorageForAnimation: observable(Project!.animated_java.use_storage_for_animation), |
53 | | - // Plugin Settings |
54 | | - bakedAnimations: observable(Project!.animated_java.baked_animations), |
55 | | - jsonFile: observable(Project!.animated_java.json_file), |
56 | | - } |
57 | | -} |
58 | | - |
59 | | -function setSettings(settings: ReturnType<typeof getSettings>) { |
60 | | - if (!Project) return |
61 | | - Project.name = settings.blueprintName.get() |
62 | | - |
63 | | - Project.setResolution(settings.textureSizeX.get(), settings.textureSizeY.get(), true) |
| 18 | +const localize = createScopedTranslator('dialog.blueprint_settings') |
64 | 19 |
|
65 | | - Project.animated_java.show_render_box = settings.showRenderBox.get() |
66 | | - Project.animated_java.auto_render_box = settings.autoRenderBox.get() |
67 | | - Project.animated_java.render_box = [settings.renderBoxX.get(), settings.renderBoxY.get()] |
68 | | - |
69 | | - // Export Settings |
70 | | - Project.animated_java.enable_plugin_mode = settings.enablePluginMode.get() |
71 | | - Project.pluginMode.set(settings.enablePluginMode.get()) // Required to update the project title. |
72 | | - Project.animated_java.export_namespace = settings.exportNamespace.get() |
73 | | - Project.animated_java.resource_pack_export_mode = |
74 | | - settings.resourcePackExportMode.get() as ExportMode |
75 | | - Project.animated_java.data_pack_export_mode = settings.dataPackExportMode.get() as ExportMode |
76 | | - Project.animated_java.target_minecraft_version = |
77 | | - settings.targetMinecraftVersion.get() as SUPPORTED_MINECRAFT_VERSIONS |
78 | | - // Resource Pack Settings |
79 | | - Project.animated_java.display_item = settings.displayItem.get() |
80 | | - Project.animated_java.custom_model_data_offset = settings.customModelDataOffset.get() |
81 | | - Project.animated_java.enable_advanced_resource_pack_settings = |
82 | | - settings.enableAdvancedResourcePackSettings.get() |
83 | | - Project.animated_java.resource_pack = settings.resourcePack.get() |
84 | | - // Data Pack Settings |
85 | | - Project.animated_java.enable_advanced_data_pack_settings = |
86 | | - settings.enableAdvancedDataPackSettings.get() |
87 | | - Project.animated_java.data_pack = settings.dataPack.get() |
88 | | - Project.animated_java.on_summon_function = settings.onSummonFunction.get() |
89 | | - Project.animated_java.on_remove_function = settings.onRemoveFunction.get() |
90 | | - Project.animated_java.on_pre_tick_function = settings.onPreTickFunction.get() |
91 | | - Project.animated_java.on_post_tick_function = settings.onPostTickFunction.get() |
92 | | - Project.animated_java.interpolation_duration = settings.interpolationDuration.get() |
93 | | - Project.animated_java.teleportation_duration = settings.teleportationDuration.get() |
94 | | - Project.animated_java.auto_update_rig_orientation = settings.autoUpdateRigOrientation.get() |
95 | | - Project.animated_java.use_storage_for_animation = settings.useStorageForAnimation.get() |
96 | | - // Plugin Settings |
97 | | - Project.animated_java.baked_animations = settings.bakedAnimations.get() |
98 | | - Project.animated_java.json_file = settings.jsonFile.get() |
99 | | - console.log('Successfully saved project settings', Project) |
100 | | -} |
101 | | - |
102 | | -export function openBlueprintSettingsDialog() { |
103 | | - if (!Project) return |
104 | | - |
105 | | - return openBlueprintSettingsv2() |
106 | | - |
107 | | - const settings = getSettings() |
108 | | - const dialog = new SvelteDialog({ |
109 | | - id: `${PACKAGE.name}:blueprintSettingsDialog`, |
110 | | - title: translate('dialog.blueprint_settings.title'), |
111 | | - width: 800, |
112 | | - component: BlueprintSettings, |
113 | | - props: settings, |
114 | | - onOpen() { |
115 | | - mount(BlueprintSettingsAds, { target: dialog.object! }) |
116 | | - dialog.object!.style.top = '' |
| 20 | +export function openBlueprintSettings() { |
| 21 | + const dialog = new SvelteDialogSidebar({ |
| 22 | + id: `animated_java_blueprint_settings`, |
| 23 | + title: 'Blueprint Settings', |
| 24 | + pages: { |
| 25 | + general: { |
| 26 | + component: General, |
| 27 | + label: localize('pages.general.title'), |
| 28 | + icon: 'settings', |
| 29 | + }, |
| 30 | + datapack: { |
| 31 | + component: Datapack, |
| 32 | + condition: () => Project.pluginMode.get() === false, |
| 33 | + label: localize('pages.datapack.title'), |
| 34 | + icon: 'database', |
| 35 | + }, |
| 36 | + resourcepack: { |
| 37 | + component: Resourcepack, |
| 38 | + condition: () => Project.pluginMode.get() === false, |
| 39 | + label: localize('pages.resource_pack.title'), |
| 40 | + icon: 'image', |
| 41 | + }, |
| 42 | + eventFunctions: { |
| 43 | + component: EventFunctions, |
| 44 | + condition: () => Project.pluginMode.get() === false, |
| 45 | + label: localize('pages.event_functions.title'), |
| 46 | + icon: 'functions', |
| 47 | + }, |
| 48 | + misc: { |
| 49 | + component: Misc, |
| 50 | + label: localize('pages.misc.title'), |
| 51 | + icon: 'tune', |
| 52 | + }, |
| 53 | + }, |
| 54 | + footer: { |
| 55 | + component: Footer, |
117 | 56 | }, |
| 57 | + pageSwitchActions: [ |
| 58 | + OPEN_DOCUMENTATION.get()!, |
| 59 | + OPEN_ABOUT.get()!, |
| 60 | + EXPORT_DEBUG.get()!, |
| 61 | + EXPORT.get()!, |
| 62 | + ], |
| 63 | + width: 1024, |
| 64 | + defaultPage: 'general', |
118 | 65 | disableKeybinds: true, |
119 | | - onConfirm() { |
120 | | - setSettings(settings) |
| 66 | + buttons: ['Close'], |
| 67 | + onClose: () => { |
121 | 68 | updateRotationConstraints() |
122 | 69 | updateAllCubeOutlines() |
123 | 70 | Canvas.updateAll() |
124 | 71 | }, |
125 | 72 | }) |
126 | | - return dialog.show() |
| 73 | + dialog.show() |
| 74 | + return dialog |
127 | 75 | } |
0 commit comments