Skip to content

Commit b2ca36f

Browse files
committed
Fix crash in EditPrefab and clean it up a bit
1 parent 78dd3c4 commit b2ca36f

3 files changed

Lines changed: 49 additions & 17 deletions

File tree

crates/spaceman-dmm/src/edit_prefab.rs

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl EditPrefab {
2525

2626
pub fn menu(&mut self, ui: &Ui) {
2727
ui.menu("Filter...", || {
28-
ui.input_text("", &mut self.filter).build();
28+
ui.input_text("##filter", &mut self.filter).build();
2929
if ui.menu_item_config("Clear").build() {
3030
self.filter.clear();
3131
}
@@ -109,31 +109,37 @@ impl EditPrefab {
109109
ui.separator();
110110
ui.text(&search.path);
111111

112-
for (name, var) in search.vars.iter() {
112+
let mut vars: Vec<_> = search
113+
.vars
114+
.iter()
115+
.filter(|v| !UNMODIFIABLE_VARS.contains(&v.0.as_str()))
116+
.collect();
117+
vars.sort_by(|a, b| a.0.cmp(&b.0));
118+
for (name, var) in vars {
113119
if !name.contains(filter.as_str()) {
114120
continue;
115121
}
116122
if let Some(decl) = var.declaration.as_ref() {
117-
let mut prefix = " ";
118-
if !decl.var_type.is_normal() {
119-
if !extra_vars {
120-
continue;
123+
let var_type = decl.var_type.flags.to_string();
124+
if var_type.is_empty() {
125+
ui.text(" ");
126+
} else if !extra_vars {
127+
continue;
128+
} else {
129+
ui.text("- ");
130+
if ui.is_item_hovered() {
131+
ui.tooltip_text(&var_type);
121132
}
122-
prefix = "-";
123133
}
134+
ui.same_line_with_spacing(0., 0.);
124135

125136
let instance_value = self.fab.vars.get(name.as_str());
126-
127137
if instance_value.is_some() {
128138
let style = ui.push_style_color(StyleColor::Text, GREEN);
129-
ui.text(format!("{} {}", prefix, name));
139+
ui.text(name);
130140
style.pop();
131141
} else {
132-
ui.text(format!("{} {}", prefix, name));
133-
}
134-
135-
if prefix == "-" && ui.is_item_hovered() {
136-
ui.tooltip_text("/tmp, /static, or /const");
142+
ui.text(name);
137143
}
138144

139145
// search_ty is seeded with ty and must be Some to get here
@@ -166,7 +172,33 @@ impl EditPrefab {
166172
}
167173
}
168174

169-
search_ty = search.parent_type();
175+
search_ty = search.parent_type_without_root();
170176
}
171177
}
172178
}
179+
180+
// DreamMaker never lets you modify these vars, so we won't either.
181+
const UNMODIFIABLE_VARS: &[&str] = &[
182+
"appearance",
183+
"bounds",
184+
"loc",
185+
"locs",
186+
"maptext_height",
187+
"maptext_width",
188+
"maptext_x",
189+
"maptext_y",
190+
"maptext",
191+
"parent_type",
192+
"particles",
193+
"pixloc",
194+
"render_source",
195+
"render_target",
196+
"type",
197+
"vars",
198+
"verbs",
199+
"vis_contents",
200+
"vis_locs",
201+
"x",
202+
"y",
203+
"z",
204+
];

crates/spaceman-dmm/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ impl EditorScene {
10891089
ui.window(&format!("{}##{}/{:?}", base.path(), uid, inst))
10901090
.opened(&mut keep)
10911091
.position(ui.io().mouse_pos, Condition::Appearing)
1092-
.size([450.0, 550.0], Condition::FirstUseEver)
1092+
.size([0.0, 550.0], Condition::Appearing)
10931093
.horizontal_scrollbar(true)
10941094
.menu_bar(true)
10951095
.build(|| {

crates/spaceman-dmm/src/tools/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl ToolBehavior for Place {
6565
ui.window(&format!("Palette: {}##place/{}", edit.path(), i))
6666
.opened(&mut keep_editor)
6767
.position(ui.io().mouse_pos, Condition::Appearing)
68-
.size([350.0, 500.0], Condition::FirstUseEver)
68+
.size([0.0, 550.0], Condition::Appearing)
6969
.horizontal_scrollbar(true)
7070
.menu_bar(true)
7171
.build(|| {

0 commit comments

Comments
 (0)