bevy_map_editor 0.4.0

Full-featured map editor for Bevy games with autotile support
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
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
//! Property inspector panel

use bevy_egui::egui;
use bevy_map_animation::SpriteData;
use bevy_map_core::{
    ComponentOverrides, EntityTypeConfig, InputConfig, InputOverrides, PhysicsConfig,
    PhysicsOverrides, SpriteConfig, SpriteOverrides,
};
use uuid::Uuid;

use crate::project::Project;
use crate::EditorState;

/// What is currently selected in the editor
#[derive(Debug, Clone, PartialEq, Default)]
pub enum Selection {
    #[default]
    None,
    Level(Uuid),
    Layer(Uuid, usize), // level_id, layer_index
    Entity(Uuid, Uuid), // level_id, entity_id
    Tileset(Uuid),
    DataType(String), // type_name
    DataInstance(Uuid),
    SpriteSheet(Uuid), // sprite sheet asset id
    Dialogue(String),  // dialogue asset id
    // Multi-select variants
    MultipleDataInstances(Vec<Uuid>),
    MultipleEntities(Vec<(Uuid, Uuid)>), // Vec of (level_id, entity_id)
}

/// Result from rendering the inspector
#[derive(Default)]
pub struct InspectorResult {
    pub delete_data_instance: Option<Uuid>,
    pub delete_entity: Option<(Uuid, Uuid)>,
    pub open_sprite_editor: Option<(String, Uuid)>,
    pub open_dialogue_editor: Option<(String, Uuid)>,
    /// Edit sprite sheet animations (opens Animation Editor)
    pub edit_sprite_sheet: Option<Uuid>,
    /// Edit sprite sheet grid settings (opens SpriteSheet Editor)
    pub edit_sprite_sheet_settings: Option<Uuid>,
    pub edit_dialogue: Option<String>,
    /// Create a new data instance and add its ID to an array property
    /// (type_name, target_instance_id, property_name)
    pub create_instance_for_array: Option<(String, Uuid, String)>,
}

/// Render the property inspector
pub fn render_inspector(
    ui: &mut egui::Ui,
    editor_state: &mut EditorState,
    project: &mut Project,
) -> InspectorResult {
    let mut result = InspectorResult::default();

    ui.heading("Inspector");
    ui.separator();

    match &editor_state.selection {
        Selection::None => {
            ui.label("Nothing selected");
        }
        Selection::Level(level_id) => {
            render_level_inspector(ui, *level_id, project);
        }
        Selection::Layer(level_id, layer_idx) => {
            render_layer_inspector(ui, *level_id, *layer_idx, project);
        }
        Selection::Entity(level_id, entity_id) => {
            if render_entity_inspector(ui, *level_id, *entity_id, project) {
                result.delete_entity = Some((*level_id, *entity_id));
            }
        }
        Selection::Tileset(tileset_id) => {
            render_tileset_inspector(ui, *tileset_id, project);
        }
        Selection::DataType(type_name) => {
            render_data_type_inspector(ui, type_name, project);
        }
        Selection::DataInstance(instance_id) => {
            if render_data_instance_inspector(ui, *instance_id, project, &mut result) {
                result.delete_data_instance = Some(*instance_id);
            }
        }
        Selection::SpriteSheet(sprite_sheet_id) => {
            render_sprite_sheet_inspector(ui, *sprite_sheet_id, project, &mut result);
        }
        Selection::Dialogue(ref dialogue_id) => {
            render_dialogue_inspector(ui, dialogue_id, project, &mut result);
        }
        Selection::MultipleDataInstances(ids) => {
            ui.label(format!("{} data instances selected", ids.len()));
            ui.label("Use context menu for bulk operations");
        }
        Selection::MultipleEntities(items) => {
            ui.label(format!("{} entities selected", items.len()));
            ui.label("Use context menu for bulk operations");
        }
    }

    result
}

fn render_level_inspector(ui: &mut egui::Ui, level_id: Uuid, project: &mut Project) {
    let Some(level) = project.get_level_mut(level_id) else {
        ui.label("Level not found");
        return;
    };

    ui.label(format!("Level: {}", level.name));
    ui.separator();

    ui.horizontal(|ui| {
        ui.label("Name:");
        ui.text_edit_singleline(&mut level.name);
    });

    ui.horizontal(|ui| {
        ui.label("Size:");
        ui.label(format!("{}x{}", level.width, level.height));
    });

    ui.label(format!("Layers: {}", level.layers.len()));
    ui.label(format!("Entities: {}", level.entities.len()));
}

fn render_layer_inspector(
    ui: &mut egui::Ui,
    level_id: Uuid,
    layer_idx: usize,
    project: &mut Project,
) {
    let Some(level) = project.get_level_mut(level_id) else {
        ui.label("Level not found");
        return;
    };

    let Some(layer) = level.layers.get_mut(layer_idx) else {
        ui.label("Layer not found");
        return;
    };

    ui.label(format!("Layer: {}", layer.name));
    ui.separator();

    ui.horizontal(|ui| {
        ui.label("Name:");
        ui.text_edit_singleline(&mut layer.name);
    });

    ui.horizontal(|ui| {
        ui.label("Visible:");
        ui.checkbox(&mut layer.visible, "");
    });
}

fn render_entity_inspector(
    ui: &mut egui::Ui,
    level_id: Uuid,
    entity_id: Uuid,
    project: &mut Project,
) -> bool {
    let mut should_delete = false;

    // Phase 1: Extract read-only schema data and entity type config before mutable borrow
    let (
        type_name,
        type_def,
        entity_type_config,
        enums,
        sprite_sheets,
        dialogue_options,
        ref_options,
        animation_names,
    ) = {
        let Some(level) = project.get_level(level_id) else {
            ui.label("Level not found");
            return false;
        };
        let Some(entity) = level.get_entity(entity_id) else {
            ui.label("Entity not found");
            return false;
        };

        let type_name = entity.type_name.clone();
        let type_def = project.schema.get_type(&type_name).cloned();
        let entity_type_config = project.get_entity_type_config(&type_name).cloned();
        let enums = project.schema.enums.clone();

        // Collect sprite sheet data (full SpriteData for embedding)
        let sprite_sheets: Vec<SpriteData> = project.sprite_sheets.clone();

        // Collect dialogue options: (id, name)
        let dialogue_options: Vec<(String, String)> = project
            .dialogues
            .iter()
            .map(|d| (d.id.clone(), d.name.clone()))
            .collect();

        // Collect ref options per type: HashMap<type_name, Vec<(id, display_name)>>
        let ref_options: std::collections::HashMap<String, Vec<(String, String)>> = project
            .data
            .instances
            .iter()
            .map(|(type_name, instances)| {
                let opts: Vec<(String, String)> = instances
                    .iter()
                    .map(|inst| {
                        let name = inst
                            .properties
                            .get("name")
                            .and_then(|v| v.as_string())
                            .unwrap_or(&inst.id.to_string())
                            .to_string();
                        (inst.id.to_string(), name)
                    })
                    .collect();
                (type_name.clone(), opts)
            })
            .collect();

        // Collect animation names from the entity's sprite sheet (if any)
        let animation_names: Vec<String> = entity_type_config
            .as_ref()
            .and_then(|cfg| cfg.sprite.as_ref())
            .and_then(|sprite_cfg| sprite_cfg.sprite_sheet_id)
            .and_then(|sheet_id| project.get_sprite_sheet(sheet_id))
            .map(|sheet| sheet.animations.keys().cloned().collect())
            .unwrap_or_default();

        (
            type_name,
            type_def,
            entity_type_config,
            enums,
            sprite_sheets,
            dialogue_options,
            ref_options,
            animation_names,
        )
    };

    // Phase 2: Mutable access for editing
    let Some(level) = project.get_level_mut(level_id) else {
        ui.label("Level not found");
        return false;
    };
    let Some(entity) = level.get_entity_mut(entity_id) else {
        ui.label("Entity not found");
        return false;
    };

    // Header
    ui.label(format!("Entity: {}", type_name));
    ui.separator();

    // Position editor
    ui.horizontal(|ui| {
        ui.label("Position:");
        ui.add(
            egui::DragValue::new(&mut entity.position[0])
                .speed(1.0)
                .prefix("X: "),
        );
        ui.add(
            egui::DragValue::new(&mut entity.position[1])
                .speed(1.0)
                .prefix("Y: "),
        );
    });

    // Properties section
    if let Some(type_def) = type_def {
        ui.separator();
        ui.label("Properties");

        for prop_def in &type_def.properties {
            // Check show_if condition
            if !should_show_property(prop_def, &entity.properties) {
                continue;
            }

            // Ensure property exists with default
            if !entity.properties.contains_key(&prop_def.name) {
                entity
                    .properties
                    .insert(prop_def.name.clone(), get_default_value(prop_def));
            }

            let value = entity.properties.get_mut(&prop_def.name).unwrap();
            let id_salt = format!("entity_{}_{}", entity_id, prop_def.name);

            // Label with required indicator
            ui.horizontal(|ui| {
                ui.label(&prop_def.name);
                if prop_def.required {
                    ui.colored_label(egui::Color32::RED, "*");
                }
            });

            // Render editor based on prop_type
            render_property_value_editor(
                ui,
                prop_def,
                value,
                &id_salt,
                &enums,
                &sprite_sheets,
                &dialogue_options,
                &ref_options,
            );
        }
    }

    // Component Overrides section
    if let Some(ref type_config) = entity_type_config {
        render_component_overrides_section(
            ui,
            entity_id,
            &mut entity.component_overrides,
            type_config,
            &animation_names,
        );
    }

    ui.separator();

    if ui.button("Delete Entity").clicked() {
        should_delete = true;
    }

    should_delete
}

fn render_tileset_inspector(ui: &mut egui::Ui, tileset_id: Uuid, project: &mut Project) {
    let Some(tileset) = project.tilesets.iter_mut().find(|t| t.id == tileset_id) else {
        ui.label("Tileset not found");
        return;
    };

    ui.label(format!("Tileset: {}", tileset.name));
    ui.separator();

    ui.horizontal(|ui| {
        ui.label("Name:");
        ui.text_edit_singleline(&mut tileset.name);
    });

    ui.horizontal(|ui| {
        ui.label("Tile Size:");
        ui.add(egui::DragValue::new(&mut tileset.tile_size).range(1..=256));
    });

    ui.label(format!("Images: {}", tileset.images.len()));
    ui.label(format!("Total Tiles: {}", tileset.total_tile_count()));
}

fn render_data_type_inspector(ui: &mut egui::Ui, type_name: &str, project: &mut Project) {
    let Some(type_def) = project.schema.get_type(type_name) else {
        ui.label("Type not found");
        return;
    };

    ui.label(format!("Data Type: {}", type_name));
    ui.separator();

    // Show type info
    ui.horizontal(|ui| {
        ui.label("Color:");
        let hex = type_def.color.trim_start_matches('#');
        if hex.len() >= 6 {
            if let (Ok(r), Ok(g), Ok(b)) = (
                u8::from_str_radix(&hex[0..2], 16),
                u8::from_str_radix(&hex[2..4], 16),
                u8::from_str_radix(&hex[4..6], 16),
            ) {
                let color = egui::Color32::from_rgb(r, g, b);
                let (rect, _) =
                    ui.allocate_exact_size(egui::vec2(50.0, 20.0), egui::Sense::hover());
                ui.painter().rect_filled(rect, 2.0, color);
                ui.label(format!("#{}", hex));
            }
        }
    });

    ui.horizontal(|ui| {
        ui.label("Placeable:");
        ui.label(if type_def.placeable { "Yes" } else { "No" });
    });

    if let Some(icon) = &type_def.icon {
        ui.horizontal(|ui| {
            ui.label("Icon:");
            ui.label(icon);
        });
    }

    // Show properties
    ui.separator();
    ui.label(format!("Properties ({}):", type_def.properties.len()));

    for prop in &type_def.properties {
        ui.horizontal(|ui| {
            ui.label(&prop.name);
            ui.label(format!("({:?})", prop.prop_type));
            if prop.required {
                ui.label("*required");
            }
        });
    }

    // Show instance count
    ui.separator();
    let instance_count = project
        .data
        .instances
        .get(type_name)
        .map(|v| v.len())
        .unwrap_or(0);
    ui.label(format!("Instances: {}", instance_count));
}

fn render_data_instance_inspector(
    ui: &mut egui::Ui,
    instance_id: Uuid,
    project: &mut Project,
    result: &mut InspectorResult,
) -> bool {
    let mut should_delete = false;

    // Phase 1: Extract read-only schema data before mutable borrow
    let (type_name, type_def, enums, sprite_sheets, dialogue_options, ref_options) = {
        let Some(instance) = project.get_data_instance(instance_id) else {
            ui.label("Instance not found");
            return false;
        };

        let type_name = instance.type_name.clone();
        let type_def = project.schema.get_type(&type_name).cloned();
        let enums = project.schema.enums.clone();

        // Collect sprite sheet data (full SpriteData for embedding)
        let sprite_sheets: Vec<SpriteData> = project.sprite_sheets.clone();

        // Collect dialogue options: (id, name)
        let dialogue_options: Vec<(String, String)> = project
            .dialogues
            .iter()
            .map(|d| (d.id.clone(), d.name.clone()))
            .collect();

        // Collect ref options per type: HashMap<type_name, Vec<(id, display_name)>>
        let ref_options: std::collections::HashMap<String, Vec<(String, String)>> = project
            .data
            .instances
            .iter()
            .map(|(type_name, instances)| {
                let opts: Vec<(String, String)> = instances
                    .iter()
                    .map(|inst| {
                        let name = inst
                            .properties
                            .get("name")
                            .and_then(|v| v.as_string())
                            .unwrap_or(&inst.id.to_string())
                            .to_string();
                        (inst.id.to_string(), name)
                    })
                    .collect();
                (type_name.clone(), opts)
            })
            .collect();

        (
            type_name,
            type_def,
            enums,
            sprite_sheets,
            dialogue_options,
            ref_options,
        )
    };

    // Phase 2: Mutable access for editing
    let Some(instance) = project.get_data_instance_mut(instance_id) else {
        ui.label("Instance not found");
        return false;
    };

    // Header
    ui.label(format!("Data Instance: {}", type_name));
    ui.separator();

    // Properties section - schema-aware editing
    if let Some(type_def) = type_def {
        for prop_def in &type_def.properties {
            // Check show_if condition
            if !should_show_property(prop_def, &instance.properties) {
                continue;
            }

            // Ensure property exists with default
            if !instance.properties.contains_key(&prop_def.name) {
                instance
                    .properties
                    .insert(prop_def.name.clone(), get_default_value(prop_def));
            }

            let value = instance.properties.get_mut(&prop_def.name).unwrap();
            let id_salt = format!("data_instance_{}_{}", instance_id, prop_def.name);

            // Label with required indicator
            ui.horizontal(|ui| {
                ui.label(&prop_def.name);
                if prop_def.required {
                    ui.colored_label(egui::Color32::RED, "*");
                }
            });

            // Render editor based on prop_type using the full property editor
            if let Some(create_type) = render_property_value_editor(
                ui,
                prop_def,
                value,
                &id_salt,
                &enums,
                &sprite_sheets,
                &dialogue_options,
                &ref_options,
            ) {
                // Handle inline instance creation for arrays
                result.create_instance_for_array =
                    Some((create_type, instance_id, prop_def.name.clone()));
            }
        }
    } else {
        // Fallback if no schema - display raw properties read-only
        ui.label("(No schema found for this type)");
        for (key, value) in instance.properties.iter() {
            ui.horizontal(|ui| {
                ui.label(format!("{}:", key));
                ui.label(format!("{:?}", value));
            });
        }
    }

    ui.separator();

    if ui.button("Delete Instance").clicked() {
        should_delete = true;
    }

    should_delete
}

fn render_sprite_sheet_inspector(
    ui: &mut egui::Ui,
    sprite_sheet_id: Uuid,
    project: &mut Project,
    result: &mut InspectorResult,
) {
    // First get mutable access to edit the name
    if let Some(sprite_sheet) = project.get_sprite_sheet_mut(sprite_sheet_id) {
        ui.horizontal(|ui| {
            ui.label("Name:");
            ui.text_edit_singleline(&mut sprite_sheet.name);
        });
    }

    // Re-get immutable reference for display
    let Some(sprite_sheet) = project.get_sprite_sheet(sprite_sheet_id) else {
        ui.label("Sprite Sheet not found");
        return;
    };

    ui.separator();

    ui.horizontal(|ui| {
        ui.label("Sheet:");
        ui.label(if sprite_sheet.sheet_path.is_empty() {
            "(not set)"
        } else {
            &sprite_sheet.sheet_path
        });
    });

    ui.horizontal(|ui| {
        ui.label("Frame size:");
        ui.label(format!(
            "{}x{}",
            sprite_sheet.frame_width, sprite_sheet.frame_height
        ));
    });

    ui.horizontal(|ui| {
        ui.label("Grid:");
        ui.label(format!(
            "{} columns x {} rows",
            sprite_sheet.columns, sprite_sheet.rows
        ));
    });

    ui.horizontal(|ui| {
        ui.label("Total frames:");
        ui.label(format!("{}", sprite_sheet.total_frames()));
    });

    ui.horizontal(|ui| {
        ui.label("Animations:");
        ui.label(format!("{}", sprite_sheet.animations.len()));
    });

    ui.separator();

    if ui.button("Edit Animations").clicked() {
        result.edit_sprite_sheet = Some(sprite_sheet_id);
    }

    if ui.button("Edit Sheet").clicked() {
        result.edit_sprite_sheet_settings = Some(sprite_sheet_id);
    }
}

fn render_dialogue_inspector(
    ui: &mut egui::Ui,
    dialogue_id: &str,
    project: &mut Project,
    result: &mut InspectorResult,
) {
    // First get mutable access to edit the name
    if let Some(dialogue) = project.get_dialogue_mut(dialogue_id) {
        ui.horizontal(|ui| {
            ui.label("Name:");
            ui.text_edit_singleline(&mut dialogue.name);
        });
    }

    // Re-get immutable reference for display
    let Some(dialogue) = project.get_dialogue(dialogue_id) else {
        ui.label("Dialogue not found");
        return;
    };

    ui.separator();

    ui.horizontal(|ui| {
        ui.label("ID:");
        ui.label(&dialogue.id);
    });

    ui.horizontal(|ui| {
        ui.label("Nodes:");
        ui.label(format!("{}", dialogue.nodes.len()));
    });

    if !dialogue.start_node.is_empty() {
        ui.horizontal(|ui| {
            ui.label("Start node:");
            ui.label(&dialogue.start_node);
        });
    }

    ui.separator();

    if ui.button("Open Editor").clicked() {
        result.edit_dialogue = Some(dialogue_id.to_string());
    }
}

// ============================================================================
// Property Editor Helpers
// ============================================================================

/// Get a default value for a property based on its definition
#[allow(deprecated)] // PropType::Sprite is deprecated but we still handle it for backwards compat
pub fn get_default_value(prop_def: &bevy_map_schema::PropertyDef) -> bevy_map_core::Value {
    use bevy_map_core::Value;
    use bevy_map_schema::PropType;

    if let Some(default) = &prop_def.default {
        return Value::from_json(default.clone());
    }

    match prop_def.prop_type {
        PropType::String | PropType::Multiline => Value::String(String::new()),
        PropType::Int => Value::Int(0),
        PropType::Float => Value::Float(0.0),
        PropType::Bool => Value::Bool(false),
        PropType::Enum => Value::String(String::new()),
        PropType::Ref => Value::Null,
        PropType::Array => Value::Array(Vec::new()),
        PropType::Point => Value::Object(
            [
                ("x".to_string(), Value::Float(0.0)),
                ("y".to_string(), Value::Float(0.0)),
            ]
            .into_iter()
            .collect(),
        ),
        PropType::Color => Value::String("#808080".to_string()),
        PropType::Sprite => Value::Null,
        PropType::Dialogue => Value::Null,
        PropType::Embedded => Value::Null,
    }
}

/// Check if a property should be shown based on its show_if condition
fn should_show_property(
    prop_def: &bevy_map_schema::PropertyDef,
    properties: &std::collections::HashMap<String, bevy_map_core::Value>,
) -> bool {
    let Some(show_if) = &prop_def.show_if else {
        return true;
    };

    if let Some((prop_name, expected)) = show_if.split_once('=') {
        if let Some(actual) = properties.get(prop_name.trim()) {
            let actual_str = match actual {
                bevy_map_core::Value::String(s) => s.clone(),
                bevy_map_core::Value::Bool(b) => b.to_string(),
                bevy_map_core::Value::Int(i) => i.to_string(),
                _ => return false,
            };
            return actual_str == expected.trim();
        }
        return false;
    }
    true
}

/// Parse a hex color string to RGB floats
fn parse_hex_color_to_rgb(hex: &str) -> [f32; 3] {
    let hex = hex.trim_start_matches('#');
    if hex.len() >= 6 {
        if let (Ok(r), Ok(g), Ok(b)) = (
            u8::from_str_radix(&hex[0..2], 16),
            u8::from_str_radix(&hex[2..4], 16),
            u8::from_str_radix(&hex[4..6], 16),
        ) {
            return [r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0];
        }
    }
    [0.5, 0.5, 0.5]
}

/// Render a property value editor based on its type
/// Returns Some(type_name) if user clicks "Create New" for an Array property
#[allow(clippy::too_many_arguments)]
#[allow(deprecated)] // PropType::Sprite is deprecated but we still handle it for backwards compat
fn render_property_value_editor(
    ui: &mut egui::Ui,
    prop_def: &bevy_map_schema::PropertyDef,
    value: &mut bevy_map_core::Value,
    id_salt: &str,
    enums: &std::collections::HashMap<String, Vec<String>>,
    sprite_sheets: &[SpriteData],
    dialogue_options: &[(String, String)],
    ref_options: &std::collections::HashMap<String, Vec<(String, String)>>,
) -> Option<String> {
    use bevy_map_core::Value;
    use bevy_map_schema::PropType;

    match prop_def.prop_type {
        PropType::String => {
            let mut s = value.as_string().unwrap_or(&String::new()).to_string();
            if ui.text_edit_singleline(&mut s).changed() {
                *value = Value::String(s);
            }
        }

        PropType::Multiline => {
            let mut s = value.as_string().unwrap_or(&String::new()).to_string();
            if ui.text_edit_multiline(&mut s).changed() {
                *value = Value::String(s);
            }
        }

        PropType::Int => {
            let mut i = value.as_int().unwrap_or(0);
            let mut drag = egui::DragValue::new(&mut i);
            let min_val = prop_def.min.map(|m| m as i64).unwrap_or(i64::MIN);
            let max_val = prop_def.max.map(|m| m as i64).unwrap_or(i64::MAX);
            drag = drag.range(min_val..=max_val);
            if ui.add(drag).changed() {
                *value = Value::Int(i);
            }
        }

        PropType::Float => {
            let mut f = value.as_float().unwrap_or(0.0);
            let mut drag = egui::DragValue::new(&mut f).speed(0.1);
            let min_val = prop_def.min.unwrap_or(f64::MIN);
            let max_val = prop_def.max.unwrap_or(f64::MAX);
            drag = drag.range(min_val..=max_val);
            if ui.add(drag).changed() {
                *value = Value::Float(f);
            }
        }

        PropType::Bool => {
            let mut b = value.as_bool().unwrap_or(false);
            if ui.checkbox(&mut b, "").changed() {
                *value = Value::Bool(b);
            }
        }

        PropType::Enum => {
            if let Some(enum_type) = &prop_def.enum_type {
                if let Some(enum_values) = enums.get(enum_type) {
                    let current = value.as_string().unwrap_or(&String::new()).to_string();
                    egui::ComboBox::from_id_salt(id_salt)
                        .selected_text(if current.is_empty() {
                            "(None)"
                        } else {
                            &current
                        })
                        .show_ui(ui, |ui| {
                            for enum_val in enum_values {
                                if ui
                                    .selectable_label(current == *enum_val, enum_val)
                                    .clicked()
                                {
                                    *value = Value::String(enum_val.clone());
                                }
                            }
                        });
                }
            }
        }

        PropType::Ref => {
            if let Some(ref_type) = &prop_def.ref_type {
                let current_id = value.as_string().unwrap_or(&String::new()).to_string();
                let instances = ref_options.get(ref_type);
                let current_name = instances
                    .and_then(|opts| opts.iter().find(|(id, _)| *id == current_id))
                    .map(|(_, name)| name.as_str())
                    .unwrap_or("(None)");

                egui::ComboBox::from_id_salt(id_salt)
                    .selected_text(current_name)
                    .show_ui(ui, |ui| {
                        if ui
                            .selectable_label(current_id.is_empty(), "(None)")
                            .clicked()
                        {
                            *value = Value::Null;
                        }
                        if let Some(opts) = instances {
                            for (id, name) in opts {
                                if ui.selectable_label(*id == current_id, name).clicked() {
                                    *value = Value::String(id.clone());
                                }
                            }
                        }
                    });
            }
        }

        PropType::Point => {
            let (mut x, mut y) = match value {
                Value::Object(obj) => (
                    obj.get("x").and_then(|v| v.as_float()).unwrap_or(0.0),
                    obj.get("y").and_then(|v| v.as_float()).unwrap_or(0.0),
                ),
                _ => (0.0, 0.0),
            };

            let mut changed = false;
            ui.horizontal(|ui| {
                changed |= ui
                    .add(egui::DragValue::new(&mut x).speed(1.0).prefix("X: "))
                    .changed();
                changed |= ui
                    .add(egui::DragValue::new(&mut y).speed(1.0).prefix("Y: "))
                    .changed();
            });

            if changed {
                *value = Value::Object(
                    [
                        ("x".to_string(), Value::Float(x)),
                        ("y".to_string(), Value::Float(y)),
                    ]
                    .into_iter()
                    .collect(),
                );
            }
        }

        PropType::Color => {
            let current = value
                .as_string()
                .unwrap_or(&"#808080".to_string())
                .to_string();
            let mut rgb = parse_hex_color_to_rgb(&current);

            if ui.color_edit_button_rgb(&mut rgb).changed() {
                *value = Value::String(format!(
                    "#{:02x}{:02x}{:02x}",
                    (rgb[0] * 255.0) as u8,
                    (rgb[1] * 255.0) as u8,
                    (rgb[2] * 255.0) as u8
                ));
            }
        }

        PropType::Sprite => {
            // Get current sprite ID from embedded SpriteData object only
            let current_id = match value {
                Value::Object(obj) => obj
                    .get("id")
                    .and_then(|v| v.as_string())
                    .map(|s| s.to_string()),
                _ => None,
            }
            .unwrap_or_default();

            let current_name = sprite_sheets
                .iter()
                .find(|s| s.id.to_string() == current_id)
                .map(|s| s.name.as_str())
                .unwrap_or("(None)");

            egui::ComboBox::from_id_salt(id_salt)
                .selected_text(current_name)
                .show_ui(ui, |ui| {
                    if ui
                        .selectable_label(current_id.is_empty(), "(None)")
                        .clicked()
                    {
                        *value = Value::Null;
                    }
                    for sprite_data in sprite_sheets {
                        let id_str = sprite_data.id.to_string();
                        if ui
                            .selectable_label(id_str == current_id, &sprite_data.name)
                            .clicked()
                        {
                            // Embed full SpriteData as Value::Object
                            if let Ok(json) = serde_json::to_value(sprite_data) {
                                *value = Value::from_json(json);
                            }
                        }
                    }
                });
        }

        PropType::Dialogue => {
            let current_id = value.as_string().unwrap_or(&String::new()).to_string();
            let current_name = dialogue_options
                .iter()
                .find(|(id, _)| *id == current_id)
                .map(|(_, name)| name.as_str())
                .unwrap_or("(None)");

            egui::ComboBox::from_id_salt(id_salt)
                .selected_text(current_name)
                .show_ui(ui, |ui| {
                    if ui
                        .selectable_label(current_id.is_empty(), "(None)")
                        .clicked()
                    {
                        *value = Value::Null;
                    }
                    for (id, name) in dialogue_options {
                        if ui.selectable_label(*id == current_id, name).clicked() {
                            *value = Value::String(id.clone());
                        }
                    }
                });
        }

        PropType::Array => {
            return render_array_editor(ui, prop_def, value, id_salt, ref_options);
        }

        PropType::Embedded => {
            ui.label("(embedded type)");
        }
    }

    None
}

/// Render an array editor with add/remove support
/// Returns Some(type_name) if user clicks "Create New" for a custom type
fn render_array_editor(
    ui: &mut egui::Ui,
    prop_def: &bevy_map_schema::PropertyDef,
    value: &mut bevy_map_core::Value,
    id_salt: &str,
    ref_options: &std::collections::HashMap<String, Vec<(String, String)>>,
) -> Option<String> {
    use bevy_map_core::Value;

    // Ensure value is an array
    if !matches!(value, Value::Array(_)) {
        *value = Value::Array(Vec::new());
    }

    let item_type = prop_def.item_type.as_deref().unwrap_or("String");
    let is_custom_type = ref_options.contains_key(item_type);

    // Get instances for custom type
    let instances = if is_custom_type {
        ref_options.get(item_type)
    } else {
        None
    };

    let Value::Array(items) = value else {
        return None;
    };

    let item_count = items.len();
    let mut create_new_type: Option<String> = None;

    // Show item type in header for clarity
    let header_text = if let Some(ref item_type_name) = prop_def.item_type {
        format!(
            "{}: Array<{}> ({} items)",
            prop_def.name, item_type_name, item_count
        )
    } else {
        format!("{} ({} items)", prop_def.name, item_count)
    };

    egui::CollapsingHeader::new(header_text)
        .id_salt(id_salt)
        .default_open(item_count < 5)
        .show(ui, |ui| {
            let mut to_remove = None;

            for (idx, item) in items.iter_mut().enumerate() {
                ui.horizontal(|ui| {
                    ui.label(format!("[{}]", idx));

                    // Render based on item_type
                    if is_custom_type {
                        // Custom data type - show dropdown of instances
                        let current_id = item.as_string().unwrap_or(&String::new()).to_string();
                        let current_name = instances
                            .and_then(|opts| opts.iter().find(|(id, _)| *id == current_id))
                            .map(|(_, name)| name.as_str())
                            .unwrap_or("(None)");

                        egui::ComboBox::from_id_salt(format!("{}_{}", id_salt, idx))
                            .selected_text(current_name)
                            .show_ui(ui, |ui| {
                                if ui
                                    .selectable_label(current_id.is_empty(), "(None)")
                                    .clicked()
                                {
                                    *item = Value::Null;
                                }
                                if let Some(opts) = instances {
                                    for (id, name) in opts {
                                        if ui.selectable_label(*id == current_id, name).clicked() {
                                            *item = Value::String(id.clone());
                                        }
                                    }
                                }
                            });
                    } else {
                        // Built-in types
                        match item_type {
                            "String" => {
                                let mut s = item.as_string().unwrap_or(&String::new()).to_string();
                                if ui.text_edit_singleline(&mut s).changed() {
                                    *item = Value::String(s);
                                }
                            }
                            "Int" => {
                                let mut i = item.as_int().unwrap_or(0);
                                if ui.add(egui::DragValue::new(&mut i)).changed() {
                                    *item = Value::Int(i);
                                }
                            }
                            "Float" => {
                                let mut f = item.as_float().unwrap_or(0.0);
                                if ui.add(egui::DragValue::new(&mut f).speed(0.1)).changed() {
                                    *item = Value::Float(f);
                                }
                            }
                            "Bool" => {
                                let mut b = item.as_bool().unwrap_or(false);
                                if ui.checkbox(&mut b, "").changed() {
                                    *item = Value::Bool(b);
                                }
                            }
                            _ => {
                                // Fallback for unknown types - treat as string
                                let mut s = item.as_string().unwrap_or(&String::new()).to_string();
                                if ui.text_edit_singleline(&mut s).changed() {
                                    *item = Value::String(s);
                                }
                            }
                        }
                    }

                    // Remove button
                    if ui.small_button("X").clicked() {
                        to_remove = Some(idx);
                    }
                });
            }

            // Handle removal
            if let Some(idx) = to_remove {
                items.remove(idx);
            }

            // Add buttons - different for custom types vs primitive types
            if is_custom_type {
                ui.horizontal(|ui| {
                    // Add existing instance
                    if ui.button("+ Add Existing").clicked() {
                        items.push(Value::Null);
                    }
                    // Create new instance button
                    if ui.button(format!("+ Create New {}", item_type)).clicked() {
                        create_new_type = Some(item_type.to_string());
                    }
                });
            } else {
                // Primitive type - just add button
                if ui.button("+ Add").clicked() {
                    let new_item = match item_type {
                        "String" => Value::String(String::new()),
                        "Int" => Value::Int(0),
                        "Float" => Value::Float(0.0),
                        "Bool" => Value::Bool(false),
                        _ => Value::String(String::new()),
                    };
                    items.push(new_item);
                }
            }
        });

    create_new_type
}

// ============================================================================
// Component Override Editors
// ============================================================================

/// Render the component overrides section for an entity
fn render_component_overrides_section(
    ui: &mut egui::Ui,
    entity_id: Uuid,
    overrides: &mut ComponentOverrides,
    type_config: &EntityTypeConfig,
    animation_names: &[String],
) {
    let has_physics = type_config.physics.is_some();
    let has_input = type_config.input.is_some();
    let has_sprite = type_config.sprite.is_some();

    // Only show section if at least one component is configured
    if !has_physics && !has_input && !has_sprite {
        return;
    }

    ui.separator();

    let header_id = format!("components_{}", entity_id);
    egui::CollapsingHeader::new("Components")
        .id_salt(&header_id)
        .default_open(true)
        .show(ui, |ui| {
            // Physics overrides
            if let Some(ref physics_config) = type_config.physics {
                render_physics_overrides(ui, entity_id, overrides, physics_config);
            }

            // Input overrides
            if let Some(ref input_config) = type_config.input {
                render_input_overrides(ui, entity_id, overrides, input_config);
            }

            // Sprite overrides
            if let Some(ref sprite_config) = type_config.sprite {
                render_sprite_overrides(ui, entity_id, overrides, sprite_config, animation_names);
            }

            // Reset button
            ui.add_space(8.0);
            if !overrides.is_empty() {
                if ui.button("Reset to Type Defaults").clicked() {
                    overrides.clear();
                }
            }
        });
}

/// Render physics override fields
fn render_physics_overrides(
    ui: &mut egui::Ui,
    entity_id: Uuid,
    overrides: &mut ComponentOverrides,
    physics_config: &PhysicsConfig,
) {
    let physics_id = format!("physics_{}", entity_id);
    egui::CollapsingHeader::new("Physics")
        .id_salt(&physics_id)
        .default_open(false)
        .show(ui, |ui| {
            // Ensure physics overrides exist
            let physics = overrides
                .physics
                .get_or_insert_with(PhysicsOverrides::default);

            // Gravity Scale
            render_override_field_f32(
                ui,
                "Gravity Scale",
                &format!("{}_gravity", physics_id),
                &mut physics.gravity_scale,
                physics_config.gravity_scale,
                0.01,
            );

            // Friction
            render_override_field_f32(
                ui,
                "Friction",
                &format!("{}_friction", physics_id),
                &mut physics.friction,
                physics_config.friction,
                0.01,
            );

            // Restitution
            render_override_field_f32(
                ui,
                "Restitution",
                &format!("{}_restitution", physics_id),
                &mut physics.restitution,
                physics_config.restitution,
                0.01,
            );

            // Linear Damping
            render_override_field_f32(
                ui,
                "Linear Damping",
                &format!("{}_linear_damping", physics_id),
                &mut physics.linear_damping,
                physics_config.linear_damping,
                0.1,
            );

            // Clean up empty overrides
            if physics.is_empty() {
                overrides.physics = None;
            }
        });
}

/// Render input override fields
fn render_input_overrides(
    ui: &mut egui::Ui,
    entity_id: Uuid,
    overrides: &mut ComponentOverrides,
    input_config: &InputConfig,
) {
    let input_id = format!("input_{}", entity_id);
    egui::CollapsingHeader::new("Input")
        .id_salt(&input_id)
        .default_open(false)
        .show(ui, |ui| {
            // Ensure input overrides exist
            let input = overrides.input.get_or_insert_with(InputOverrides::default);

            // Speed
            render_override_field_f32(
                ui,
                "Speed",
                &format!("{}_speed", input_id),
                &mut input.speed,
                input_config.speed,
                1.0,
            );

            // Jump Force
            if let Some(default_jump) = input_config.jump_force {
                render_override_field_f32_opt(
                    ui,
                    "Jump Force",
                    &format!("{}_jump", input_id),
                    &mut input.jump_force,
                    default_jump,
                    1.0,
                );
            }

            // Acceleration
            render_override_field_f32(
                ui,
                "Acceleration",
                &format!("{}_accel", input_id),
                &mut input.acceleration,
                input_config.acceleration,
                1.0,
            );

            // Deceleration
            render_override_field_f32(
                ui,
                "Deceleration",
                &format!("{}_decel", input_id),
                &mut input.deceleration,
                input_config.deceleration,
                1.0,
            );

            // Max Fall Speed
            if let Some(default_fall) = input_config.max_fall_speed {
                render_override_field_f32_opt(
                    ui,
                    "Max Fall Speed",
                    &format!("{}_fall", input_id),
                    &mut input.max_fall_speed,
                    default_fall,
                    1.0,
                );
            }

            // Clean up empty overrides
            if input.is_empty() {
                overrides.input = None;
            }
        });
}

/// Render sprite override fields
fn render_sprite_overrides(
    ui: &mut egui::Ui,
    entity_id: Uuid,
    overrides: &mut ComponentOverrides,
    sprite_config: &SpriteConfig,
    animation_names: &[String],
) {
    let sprite_id = format!("sprite_{}", entity_id);
    egui::CollapsingHeader::new("Sprite")
        .id_salt(&sprite_id)
        .default_open(false)
        .show(ui, |ui| {
            // Ensure sprite overrides exist
            let sprite = overrides
                .sprite
                .get_or_insert_with(SpriteOverrides::default);

            // Scale
            let default_scale = sprite_config.scale.unwrap_or(1.0);
            render_override_field_f32_opt(
                ui,
                "Scale",
                &format!("{}_scale", sprite_id),
                &mut sprite.scale,
                default_scale,
                0.1,
            );

            // Default Animation (dropdown)
            let default_anim = sprite_config.default_animation.as_deref().unwrap_or("idle");

            ui.horizontal(|ui| {
                ui.label("Animation:");

                let current = sprite.default_animation.as_deref().unwrap_or(default_anim);
                let is_overridden = sprite.default_animation.is_some();

                // Show indicator if overridden
                if is_overridden {
                    ui.colored_label(egui::Color32::YELLOW, "*");
                }

                egui::ComboBox::from_id_salt(format!("{}_anim", sprite_id))
                    .selected_text(current)
                    .show_ui(ui, |ui| {
                        // Option to use type default
                        if ui
                            .selectable_label(
                                !is_overridden,
                                format!("(default: {})", default_anim),
                            )
                            .clicked()
                        {
                            sprite.default_animation = None;
                        }

                        // Animation options
                        for anim_name in animation_names {
                            let selected = is_overridden
                                && sprite.default_animation.as_deref() == Some(anim_name);
                            if ui.selectable_label(selected, anim_name).clicked() {
                                sprite.default_animation = Some(anim_name.clone());
                            }
                        }
                    });

                // Show default hint
                if !is_overridden {
                    ui.label(
                        egui::RichText::new(format!("(def: {})", default_anim))
                            .weak()
                            .small(),
                    );
                }
            });

            // Clean up empty overrides
            if sprite.is_empty() {
                overrides.sprite = None;
            }
        });
}

/// Render a single f32 override field with default hint
fn render_override_field_f32(
    ui: &mut egui::Ui,
    label: &str,
    id: &str,
    value: &mut Option<f32>,
    default: f32,
    speed: f32,
) {
    ui.horizontal(|ui| {
        ui.label(format!("{}:", label));

        let is_overridden = value.is_some();
        let current = value.unwrap_or(default);

        // Show indicator if overridden
        if is_overridden {
            ui.colored_label(egui::Color32::YELLOW, "*");
        }

        // Value editor - use push_id for stable ID to maintain focus while editing
        let mut edit_val = current;
        let response = ui
            .push_id(id, |ui| {
                ui.add(
                    egui::DragValue::new(&mut edit_val)
                        .speed(speed)
                        .min_decimals(1)
                        .max_decimals(2),
                )
            })
            .inner;

        if response.changed() {
            // If value changed, set the override
            *value = Some(edit_val);
        }

        // Show default hint
        ui.label(
            egui::RichText::new(format!("(def: {:.1})", default))
                .weak()
                .small(),
        );

        // Reset button (only if overridden)
        if is_overridden {
            if ui
                .small_button("")
                .on_hover_text("Reset to default")
                .clicked()
            {
                *value = None;
            }
        }
    });
}

/// Render a single optional f32 override field (for fields that can be None at type level)
fn render_override_field_f32_opt(
    ui: &mut egui::Ui,
    label: &str,
    id: &str,
    value: &mut Option<f32>,
    default: f32,
    speed: f32,
) {
    // Same as render_override_field_f32 for now
    render_override_field_f32(ui, label, id, value, default, speed);
}