Skip to content

Commit

Permalink
fix fname obliteration
Browse files Browse the repository at this point in the history
  • Loading branch information
bananaturtlesandwich committed Aug 13, 2023
1 parent 0e0c36b commit f8d2a23
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.10.0"
edition = "2021"

[dependencies]
unreal_asset = { git = "https://github.com/astrotechies/unrealmodding", package = "unreal_asset", rev = "6e028cc" }
unreal_asset = { git = "https://github.com/astrotechies/unrealmodding", package = "unreal_asset", rev = "dfcc3e2" }
unpak = { version = "1.0", features = ["asset-paths"] }
glam = { version = "0.23", features = ["fast-math", "bytemuck"] }
eframe = { version = "0.22", default-features = false, features = ["wgpu", "persistence"]}
Expand Down
35 changes: 21 additions & 14 deletions src/actor/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,30 @@ fn text(ui: &mut egui::Ui, val: &mut String) {
}

fn fname(ui: &mut egui::Ui, name: &mut FName) {
if let FName::Backed {
index,
number,
name_map,
..
} = name
{
if *number >= 0 {
let string = name_map.get_ref().get_owned_name(*index);
let f = name_map.get_mut().add_fname_with_number(&string, -1);
*name = f;
}
}
match name {
FName::Backed {
index, name_map, ..
} => text(ui, name_map.get_mut().get_name_reference_mut(*index)),
} => {
let mut map = name_map.get_mut();
// inline text() to get the response
let res = egui::TextEdit::singleline(map.get_name_reference_mut(*index))
.clip_text(false)
.show(ui)
.response;
drop(map);
if res.gained_focus() {
let content = name_map.get_ref().get_owned_name(*index);
// create a unique fname for editing which shouldn't be used otherwise
let i = name_map.get_mut().add_name_reference(content, true);
let f = name_map.get_ref().create_fname(i, -1);
*name = f;
} else if res.lost_focus() {
let content = name_map.get_ref().get_owned_name(*index);
let i = name_map.get_mut().add_name_reference(content, false);
let f = name_map.get_ref().create_fname(i, 0);
*name = f;
}
}
FName::Dummy { value, .. } => text(ui, value),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ impl Stove {
modifiers,
} => match pressed {
true => {
if !hovered || modifiers.ctrl || *repeat {
if !hovered || modifiers.ctrl || *repeat || ctx.wants_keyboard_input() {
return;
}
self.filter = match key {
Expand Down

0 comments on commit f8d2a23

Please sign in to comment.