souprune 0.5.1

A game framework designed specifically for Deltarune / Undertale fangames.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
//! # RON UI Layout Documentation / RON UI 布局文档
//!
//! This module defines the structure of the RON UI layout files used in SoupRune.
//!
//! 本模块定义了 SoupRune 中使用的 RON UI 布局文件的结构。
//!
//! ---
//!
//! ## File Structure / 文件结构
//!
//! ```ron
//! (
//!     version: 1,
//!     roots: [
//!         (
//!             name: "MyNode",
//!             // Node properties... / 节点属性...
//!         )
//!     ]
//! )
//! ```
//!
//! ---
//!
//! ## Node Properties / 节点属性
//!
//! ### Text Transform / 文本变换
//!
//! Texts use a `transform` field to define position, rotation, and scale.
//!
//! 文本使用 `transform` 字段定义位置、旋转和缩放。
//!
//! ```ron
//! transform: (
//!     translation: (x: 10.0, y: 20.0, z: 1.0), // Required / 必须
//!     rotation: Some(45.0),                    // Optional (degrees) / 可选(角度)
//!     scale: Some((x: 1.5, y: 1.5, z: 1.0)),   // Optional / 可选
//! )
//! ```
//!
//! ### Cursor Configuration / 光标配置
//!
//! Cursors can be positioned dynamically using `default_translation` or statically using `transform`.
//!
//! 光标可以使用 `default_translation` 进行动态定位,或使用 `transform` 进行静态定位。
//!
//! ```ron
//! cursor: Some((
//!     sprite_path: "common/heartsmall",
//!
//!     // Mode 1: Dynamic Logic / 模式 1:动态逻辑
//!     // Used for menus where the cursor moves between options.
//!     // 用于光标在选项之间移动的菜单。
//!     default_translation: Some(Linear(
//!         origin: (x: 0.0, y: 0.0, z: 0.0),
//!         step: (x: 0.0, y: -20.0, z: 0.0),
//!     )),
//!
//!     // Mode 2: Static Transform / 模式 2:静态变换
//!     transform: Some((
//!         // Used if default_translation is missing.
//!         // 当 default_translation 缺失时使用。
//!         translation: Some((x: 10.0, y: 10.0, z: 2.0)),
//!
//!         rotation: Some(0.0),
//!         scale: Some((x: 1.0, y: 1.0, z: 1.0)),
//!     )),
//! ))
//! ```
//!
//! ### Conditional Styles / 条件样式
//!
//! Change text color based on game state.
//!
//! 根据游戏状态改变文本颜色。
//!
//! ```ron
//! conditional_style: Some((
//!     condition: "player.inventory.is_empty",
//!     color: (r: 0.5, g: 0.5, b: 0.5, a: 1.0),
//! ))
//! ```
//!
//! ### Variable Substitution / 变量替换
//!
//! {@path}: Look up in PlayerData. / 在 PlayerData 中查找 (e.g., `{@player.hp}`).
//!
//! ### Global Triggers / 全局触发器
//!
//! Define global actions that trigger state changes.
//!
//! 定义触发状态更改的全局操作。
//!
//! ```ron
//! global_triggers: Some({
//!     "Menu": [
//!         (
//!             target_state: "Backpack",
//!             sound: Some("choice.wav"),
//!             allowed_states: Some(["Normal"]),
//!         ),
//!     ],
//! }),
//! ```

use bevy::prelude::*;
use bevy::ui::{AlignItems, FlexDirection, JustifyContent, PositionType, Val};
use serde::Deserialize;
use std::collections::HashMap;

#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
pub enum UiFlexDirection {
    #[default]
    Row,
    Column,
    RowReverse,
    ColumnReverse,
}

impl From<UiFlexDirection> for FlexDirection {
    fn from(val: UiFlexDirection) -> Self {
        match val {
            UiFlexDirection::Row => FlexDirection::Row,
            UiFlexDirection::Column => FlexDirection::Column,
            UiFlexDirection::RowReverse => FlexDirection::RowReverse,
            UiFlexDirection::ColumnReverse => FlexDirection::ColumnReverse,
        }
    }
}

#[derive(Asset, TypePath, Debug, Deserialize, Clone)]
pub struct UILayoutAsset {
    #[allow(dead_code)]
    pub version: u32,
    pub roots: Vec<UINodeDef>,
    #[serde(default)]
    pub navigation: Option<HashMap<String, NavigationRuleDef>>,
    #[serde(default)]
    pub transitions: Option<HashMap<String, LayerTransitionsDef>>,
    #[serde(default)]
    pub global_triggers: Option<HashMap<String, Vec<GlobalTriggerRuleDef>>>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct GlobalTriggerRuleDef {
    pub target_state: String,
    #[serde(default)]
    pub sound: Option<String>,
    #[serde(default)]
    pub allowed_states: Option<Vec<String>>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct UINodeDef {
    pub name: String,
    #[serde(default)]
    pub tags: Vec<String>,
    #[serde(default)]
    #[allow(dead_code)]
    pub style: StyleDef,
    #[serde(default)]
    pub visibility_rule: Option<UIVisibilityRuleDef>,
    #[serde(default)]
    #[allow(dead_code)]
    pub background_color: Option<SerializableColor>,
    #[serde(default)]
    #[allow(dead_code)]
    pub border_color: Option<SerializableColor>,
    #[serde(default)]
    #[allow(dead_code)]
    pub image: Option<ImageDef>,
    #[serde(default)]
    pub sprite: Option<SpriteDef>,
    #[serde(default)]
    pub texts: Vec<TextDef>,
    #[serde(default)]
    pub cursor: Option<CursorDef>,
    #[serde(default)]
    #[serde(alias = "ui_box_logic")]
    pub ui_shape_logic: Option<UIBoxLogicDef>,
    #[serde(default)]
    #[allow(dead_code)]
    pub children: Vec<UINodeDef>,
    /// If true, this UI node will be anchored to the camera and follow its movement.
    /// This is useful for HUD elements that should stay fixed on screen.
    /// Default is true for top-level nodes with ui_shape_logic.
    ///
    /// 如果为 true,此 UI 节点将锚定到摄像机并跟随其移动。
    /// 这对于应该固定在屏幕上的 HUD 元素很有用。
    /// 对于带有 ui_shape_logic 的顶级节点,默认为 true。
    #[serde(default = "default_camera_anchored")]
    pub camera_anchored: bool,
}

fn default_camera_anchored() -> bool {
    true
}

#[allow(dead_code)]
#[derive(Debug, Deserialize, Clone, Default)]
pub struct StyleDef {
    #[serde(default)]
    pub width: Option<SerializableVal>,
    #[serde(default)]
    pub height: Option<SerializableVal>,
    #[serde(default)]
    pub left: Option<SerializableVal>,
    #[serde(default)]
    pub right: Option<SerializableVal>,
    #[serde(default)]
    pub top: Option<SerializableVal>,
    #[serde(default)]
    pub bottom: Option<SerializableVal>,
    #[serde(default)]
    pub position_type: Option<SerializablePositionType>,
    #[serde(default)]
    pub flex_direction: Option<UiFlexDirection>,
    #[serde(default)]
    pub justify_content: Option<SerializableJustifyContent>,
    #[serde(default)]
    pub align_items: Option<SerializableAlignItems>,
}

#[derive(Debug, Deserialize, Clone)]
pub enum SerializableVal {
    Auto,
    Px(f32),
    Percent(f32),
    Vw(f32),
    Vh(f32),
}

impl From<SerializableVal> for Val {
    fn from(val: SerializableVal) -> Self {
        match val {
            SerializableVal::Auto => Val::Auto,
            SerializableVal::Px(v) => Val::Px(v),
            SerializableVal::Percent(v) => Val::Percent(v),
            SerializableVal::Vw(v) => Val::Vw(v),
            SerializableVal::Vh(v) => Val::Vh(v),
        }
    }
}

#[derive(Debug, Deserialize, Clone)]
pub enum SerializablePositionType {
    Relative,
    Absolute,
}

impl From<SerializablePositionType> for PositionType {
    fn from(val: SerializablePositionType) -> Self {
        match val {
            SerializablePositionType::Relative => PositionType::Relative,
            SerializablePositionType::Absolute => PositionType::Absolute,
        }
    }
}

#[derive(Debug, Deserialize, Clone)]
pub enum SerializableJustifyContent {
    Start,
    End,
    Center,
    SpaceBetween,
    SpaceAround,
    SpaceEvenly,
}

impl From<SerializableJustifyContent> for JustifyContent {
    fn from(val: SerializableJustifyContent) -> Self {
        match val {
            SerializableJustifyContent::Start => JustifyContent::Start,
            SerializableJustifyContent::End => JustifyContent::End,
            SerializableJustifyContent::Center => JustifyContent::Center,
            SerializableJustifyContent::SpaceBetween => JustifyContent::SpaceBetween,
            SerializableJustifyContent::SpaceAround => JustifyContent::SpaceAround,
            SerializableJustifyContent::SpaceEvenly => JustifyContent::SpaceEvenly,
        }
    }
}

#[derive(Debug, Deserialize, Clone)]
pub enum SerializableAlignItems {
    Start,
    End,
    Center,
    Baseline,
    Stretch,
}

impl From<SerializableAlignItems> for AlignItems {
    fn from(val: SerializableAlignItems) -> Self {
        match val {
            SerializableAlignItems::Start => AlignItems::Start,
            SerializableAlignItems::End => AlignItems::End,
            SerializableAlignItems::Center => AlignItems::Center,
            SerializableAlignItems::Baseline => AlignItems::Baseline,
            SerializableAlignItems::Stretch => AlignItems::Stretch,
        }
    }
}

#[derive(Debug, Deserialize, Clone)]
pub struct SerializableColor {
    pub r: f32,
    pub g: f32,
    pub b: f32,
    pub a: f32,
}

impl From<SerializableColor> for Color {
    fn from(val: SerializableColor) -> Self {
        Color::srgba(val.r, val.g, val.b, val.a)
    }
}

#[derive(Debug, Deserialize, Clone)]
pub struct DynamicColor {
    pub r: FloatOrExpr,
    pub g: FloatOrExpr,
    pub b: FloatOrExpr,
    pub a: FloatOrExpr,
}

impl DynamicColor {
    pub fn to_static_color(&self) -> Color {
        Color::srgba(
            self.r.as_float(),
            self.g.as_float(),
            self.b.as_float(),
            self.a.as_float(),
        )
    }

    pub fn is_dynamic(&self) -> bool {
        self.r.is_dynamic() || self.g.is_dynamic() || self.b.is_dynamic() || self.a.is_dynamic()
    }
}

#[derive(Debug, Deserialize, Clone)]
pub struct UIVisibilityRuleDef {
    pub rule_type: String,
    #[serde(default)]
    pub layers: Option<Vec<String>>,
}

#[allow(dead_code)]
#[derive(Debug, Deserialize, Clone)]
pub struct ImageDef {
    pub path: String,
    #[serde(default)]
    pub color: Option<SerializableColor>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct SpriteDef {
    /// Path to texture or animation config file.
    ///
    /// 纹理路径或动画配置文件的路径。
    pub path: String,
    /// If true, the path is treated as an animation config (.animation.ron).
    /// If false, it's treated as a static image.
    ///
    /// 如果为 true,则将路径视为动画配置 (.animation.ron)。
    /// 如果为 false,则将其视为静态图像。
    #[serde(default)]
    pub is_animation: bool,
    #[serde(default)]
    pub initial_state: Option<String>,
    #[serde(default)]
    pub color: Option<SerializableColor>,
    #[serde(default)]
    pub flip_x: bool,
    #[serde(default)]
    pub flip_y: bool,
    #[serde(default)]
    pub transform: Option<SerializableTransform>,
    /// Optional custom shader path for sprite material.
    /// Enables data-driven shader effects on sprites (e.g., HP bar gradients).
    ///
    /// 可选的精灵材质自定义着色器路径。
    /// 启用精灵的数据驱动着色器效果(例如HP条渐变)。
    #[serde(default)]
    pub custom_shader: Option<String>,
    /// Shader parameters passed via uniform data.
    /// Used with custom_shader to pass dynamic values (e.g., HP percentage).
    ///
    /// 通过uniform数据传递的着色器参数。
    /// 与 custom_shader 一起使用以传递动态值(例如HP百分比)。
    #[serde(default)]
    pub shader_params: Option<DynamicColor>,
    #[serde(default)]
    pub pivot: Option<SerializableVec2>,
}

#[derive(Debug, Deserialize, Clone)]
pub enum UIFontDef {
    DeterminationMono,
    DeterminationSans,
    Hud,
    BattleHud,
}

impl From<UIFontDef> for super::components::UIFont {
    fn from(val: UIFontDef) -> Self {
        match val {
            UIFontDef::DeterminationMono => super::components::UIFont::DeterminationMono,
            UIFontDef::DeterminationSans => super::components::UIFont::DeterminationSans,
            UIFontDef::Hud => super::components::UIFont::Hud,
            UIFontDef::BattleHud => super::components::UIFont::BattleHud,
        }
    }
}

#[derive(Debug, Deserialize, Clone)]
#[serde(untagged)]
pub enum FloatOrExpr {
    Static(f32),
    Dynamic(String),
}

impl FloatOrExpr {
    pub fn as_float(&self) -> f32 {
        match self {
            FloatOrExpr::Static(v) => *v,
            FloatOrExpr::Dynamic(_) => 0.0,
        }
    }

    pub fn as_expr(&self) -> Option<&String> {
        match self {
            FloatOrExpr::Dynamic(s) => Some(s),
            _ => None,
        }
    }

    pub fn is_dynamic(&self) -> bool {
        matches!(self, FloatOrExpr::Dynamic(_))
    }
}

#[derive(Debug, Deserialize, Clone)]
pub struct SerializableVec3 {
    pub x: FloatOrExpr,
    pub y: FloatOrExpr,
    pub z: FloatOrExpr,
}

impl SerializableVec3 {
    pub fn to_static_vec3(&self) -> Vec3 {
        Vec3::new(self.x.as_float(), self.y.as_float(), self.z.as_float())
    }

    pub fn is_dynamic(&self) -> bool {
        self.x.is_dynamic() || self.y.is_dynamic() || self.z.is_dynamic()
    }
}

#[derive(Debug, Deserialize, Clone)]
pub struct SerializableVec2 {
    pub x: f32,
    pub y: f32,
}

impl From<SerializableVec2> for Vec2 {
    fn from(val: SerializableVec2) -> Self {
        Vec2::new(val.x, val.y)
    }
}

#[derive(Debug, Deserialize, Clone)]
pub struct SerializableTransform {
    pub translation: SerializableVec3,
    #[serde(default)]
    pub rotation: Option<f32>,
    #[serde(default)]
    pub scale: Option<SerializableVec3>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct TextDef {
    pub id: String,
    #[serde(default)]
    pub content: Option<String>,
    pub font: UIFontDef,
    pub world_scale: SerializableVec2,
    pub color: SerializableColor,
    pub transform: SerializableTransform,
    #[serde(default)]
    pub line_height: Option<f32>,
    #[serde(default)]
    pub conditional_style: Option<ConditionalStyleDef>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct ConditionalStyleDef {
    pub condition: String,
    pub color: SerializableColor,
}

#[derive(Debug, Deserialize, Clone)]
pub struct CursorDef {
    #[allow(dead_code)]
    pub sprite_path: String,
    #[serde(default)]
    pub default_translation: Option<BoxCursorPositionDef>,
    #[serde(default)]
    pub overrides: HashMap<String, BoxCursorPositionDef>,
    #[serde(default)]
    pub visibility_rule: Option<UIVisibilityRuleDef>,
    #[serde(default)]
    pub transform: Option<CursorTransformDef>,
}

#[derive(Debug, Deserialize, Clone)]
pub enum BoxCursorPositionDef {
    Static(SerializableVec3),
    Linear {
        origin: SerializableVec3,
        step: SerializableVec3,
    },
    Custom {
        positions: Vec<SerializableVec3>,
    },
}

#[derive(Debug, Deserialize, Clone)]
pub struct CursorTransformDef {
    #[serde(default)]
    pub translation: Option<SerializableVec3>,
    #[serde(default)]
    pub scale: Option<SerializableVec3>,
    #[serde(default)]
    pub rotation: Option<f32>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct UIBoxLogicDef {
    pub width: f32,
    pub height: f32,
    #[serde(default)]
    pub border_width: f32,
    pub offset: SerializableVec3,
    /// Optional custom fill shader path for data-driven shader loading.
    /// Example: "shared/shaders/hp_bar.wgsl"
    ///
    /// 可选的自定义填充着色器路径,用于数据驱动的着色器加载。
    /// 示例:"shared/shaders/hp_bar.wgsl"
    #[serde(default)]
    pub fill_shader: Option<String>,
    /// Optional path to load a complex SmudShape structure from file.
    /// If None, generates a single SmudShape (default behavior).
    /// Example: "shared/ui_structures/ui_box.smud.ron" for classic Undertale-style box.
    ///
    /// 可选的路径,用于从文件加载复杂的 SmudShape 结构。
    /// 如果为 None,则生成单个 SmudShape(默认行为)。
    /// 示例:"shared/ui_structures/ui_box.smud.ron" 用于经典 Undertale 风格盒子。
    #[serde(default)]
    pub structure_file: Option<String>,
    /// Fill color for the shape. Defaults to BLACK.
    /// For HP bar shaders, this color is used as a data bus (r=hp%, g=lag%, b=width, a=height).
    ///
    /// 形状的填充颜色。默认为黑色。
    /// 对于血条着色器,此颜色用作数据总线(r=血量%, g=延迟%, b=宽度, a=高度)。
    #[serde(default)]
    pub fill_color: Option<SerializableColor>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct NavigationRuleDef {
    #[serde(default)]
    pub mappings: HashMap<String, isize>,
    #[serde(default)]
    pub looping: bool,
    #[serde(default)]
    pub min_index: Option<IndexBoundDef>,
    #[serde(default)]
    pub max_index: Option<IndexBoundDef>,
    #[serde(default)]
    pub sound_on_navigate: Option<String>,
}

#[derive(Debug, Deserialize, Clone)]
#[serde(untagged)]
pub enum IndexBoundDef {
    Static(usize),
    Dynamic(String),
}

#[derive(Debug, Deserialize, Clone)]
pub struct LayerTransitionsDef {
    #[serde(default)]
    pub on_confirm: Option<Vec<TransitionRuleDef>>,
    #[serde(default)]
    pub on_cancel: Option<TransitionActionDef>,
    #[serde(default)]
    pub sound_on_confirm: Option<String>,
    #[serde(default)]
    pub sound_on_cancel: Option<String>,
}

#[derive(Debug, Deserialize, Clone)]
pub struct TransitionRuleDef {
    #[serde(default)]
    pub condition: Option<String>,
    pub action: TransitionActionDef,
}

#[derive(Debug, Deserialize, Clone)]
pub enum TransitionActionDef {
    GotoLayer(String),
    PopState,
    PushState(String),
}

// ============================================================================
// SmudStructure Asset Definition
// SmudStructure 资产定义
// ============================================================================

/// Asset type for SmudShape structure definitions.
/// Loaded from `.smud.ron` files to define complex SDF shape hierarchies.
///
/// SmudShape 结构定义的资产类型。
/// 从 `.smud.ron` 文件加载,用于定义复杂的 SDF 形状层次结构。
#[derive(Asset, TypePath, Debug, Deserialize, Clone)]
pub struct SmudStructureAsset {
    /// Number of SmudShape layers in this structure.
    /// Used to determine expected entity count during updates.
    ///
    /// 此结构中的 SmudShape 层数。
    /// 用于在更新时确定预期的实体数量。
    pub layer_count: usize,

    /// The root layer definition.
    ///
    /// 根层定义。
    pub root: SmudLayerDef,
}

/// Definition for a single SmudShape layer.
///
/// 单个 SmudShape 层的定义。
#[derive(Debug, Deserialize, Clone)]
pub struct SmudLayerDef {
    /// Name for this layer (used for entity naming).
    ///
    /// 此层的名称(用于实体命名)。
    pub name: String,

    /// SDF type for this layer.
    ///
    /// 此层的 SDF 类型。
    pub sdf_type: SmudSdfType,

    /// Color source for this layer.
    ///
    /// 此层的颜色来源。
    #[serde(default)]
    pub color_source: SmudColorSource,

    /// Z offset for this layer's transform.
    ///
    /// 此层变换的 Z 偏移。
    #[serde(default = "default_z_offset")]
    pub z_offset: f32,

    /// Whether this layer should have the UIBoxFiller marker.
    ///
    /// 此层是否应该有 UIBoxFiller 标记。
    #[serde(default)]
    pub is_filler: bool,

    /// Child layers (nested SmudShapes).
    ///
    /// 子层(嵌套的 SmudShape)。
    #[serde(default)]
    pub children: Vec<SmudLayerDef>,
}

fn default_z_offset() -> f32 {
    0.1
}

/// SDF type definition for a SmudShape layer.
///
/// SmudShape 层的 SDF 类型定义。
#[derive(Debug, Deserialize, Clone)]
pub enum SmudSdfType {
    /// Use the outer SDF (box dimensions + border width).
    ///
    /// 使用外部 SDF(盒子尺寸 + 边框宽度)。
    Outer,
    /// Use the inner SDF (box dimensions only).
    ///
    /// 使用内部 SDF(仅盒子尺寸)。
    Inner,
}

/// Color source for a SmudShape layer.
///
/// SmudShape 层的颜色来源。
#[derive(Debug, Deserialize, Clone, Default)]
pub enum SmudColorSource {
    /// Use the fill_color from UIBox.
    ///
    /// 使用 UIBox 的 fill_color。
    #[default]
    FillColor,
    /// Use a fixed white color.
    ///
    /// 使用固定的白色。
    White,
    /// Use a custom color.
    ///
    /// 使用自定义颜色。
    Custom(SerializableColor),
}