mirror of
https://github.com/PR0M3TH3AN/Artstr-Studio.git
synced 2026-10-27 08:40:39 +00:00
Metadata: auto-pick category for slide / deck / pixel / custom art
Creating a Slide, Slide Deck, Pixel Art, or Custom Art template
already auto-set state.meta.category in applyLayout — but the
auto-fill was inconsistent (slide / deck / pixelart unconditionally
overwrote, customart only filled when empty) AND it didn't apply
when importing / forking a design whose payload arrived without
a category set.
Fix:
- defaultCategoryForMode(mode) — new shared helper that maps the
canvas modes to their canonical mediaCategories entries:
'slide' → 'slide'
'deck' → 'slide-deck'
'pixelart' → 'pixel-art'
'customart'→ 'custom-art'
Physical-media modes (cover / disc / jewel / disc-design) return
'' so the user picks DVD / Blu-ray / PS3 / etc. — there's no one
obvious default.
- syncInputs runs the helper at the top: if state.meta.category is
empty, fill it from the current mode. Idempotent — leaves a
user-picked value alone. Covers BOTH create-new and import /
fork / loadProjectFromText paths via the one entry point all
state changes pass through.
- applyLayout's inline mode → category switch replaced with the
shared helper, also made consistently only-if-empty so a
user-picked category survives a mode switch.
This commit is contained in:
1 parent
fb7a00d522
commit
817ab051f0
1 file changed
+31
-8
+31
-8
@@ -7832,8 +7832,30 @@
|
||||
render();
|
||||
}
|
||||
|
||||
// Map a template / app mode to the canonical mediaCategories value
|
||||
// that makes sense for it. Physical-media modes (cover / disc /
|
||||
// jewel / disc-design) return '' so the user picks DVD / Blu-ray /
|
||||
// PS3 / etc. — there's no single right answer there.
|
||||
function defaultCategoryForMode(mode) {
|
||||
switch (mode) {
|
||||
case 'slide': return 'slide';
|
||||
case 'deck': return 'slide-deck';
|
||||
case 'pixelart': return 'pixel-art';
|
||||
case 'customart':return 'custom-art';
|
||||
default: return '';
|
||||
}
|
||||
}
|
||||
|
||||
function syncInputs() {
|
||||
const isDesignerApp = state.appMode === 'designer';
|
||||
// Auto-fill the category when it's empty and the current mode has
|
||||
// a canonical default. Applies to brand-new templates created via
|
||||
// applyLayout AND to imports / forks that arrived without a
|
||||
// category set. Idempotent: leaves a user-picked category alone.
|
||||
if (state.meta && !state.meta.category) {
|
||||
const def = defaultCategoryForMode(isDesignerApp ? 'disc-design' : state.templateMode);
|
||||
if (def) state.meta.category = def;
|
||||
}
|
||||
const layoutActive = {
|
||||
cover: !isDesignerApp && state.templateMode === 'cover',
|
||||
disc: !isDesignerApp && state.templateMode === 'disc',
|
||||
@@ -24250,14 +24272,15 @@
|
||||
state.preset = 'dvd';
|
||||
Object.assign(state, presets.dvd);
|
||||
}
|
||||
// First time into Custom Art / Slide, default the category and (for a
|
||||
// slide) lock the canvas to a 16:9 resolution.
|
||||
// Slides and decks always classify under their own category; Custom
|
||||
// Art just gets a default the user can override.
|
||||
if (layout === 'slide') state.meta.category = 'slide';
|
||||
else if (layout === 'deck') state.meta.category = 'slide-deck';
|
||||
else if (layout === 'pixelart') state.meta.category = 'pixel-art';
|
||||
else if (layout === 'customart' && !state.meta.category) state.meta.category = 'custom-art';
|
||||
// First time into Custom Art / Slide / Deck / Pixel Art, default
|
||||
// the category based on the layout (slide / slide-deck / pixel-art
|
||||
// / custom-art). Only fills when empty so a user-picked category
|
||||
// sticks across switches. Lock the canvas to 16:9 for slides
|
||||
// below.
|
||||
if (!state.meta.category) {
|
||||
const def = defaultCategoryForMode(layout);
|
||||
if (def) state.meta.category = def;
|
||||
}
|
||||
if (layout === 'pixelart' && !state.pixelArt) state.pixelArt = defaultPixelArt(32, 32);
|
||||
if (layout === 'slide') {
|
||||
const ca = state.customArt || {};
|
||||
|
||||
Reference in new issue
Block a user