Skip to content

Commit

Permalink
fix: only the last weapon/inventory can be None
Browse files Browse the repository at this point in the history
or remaining items are ignored by the game
  • Loading branch information
mokurin000 committed Feb 17, 2024
1 parent 50ebc06 commit 8a9f137
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/app/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ pub fn draw_window(ui: &mut Ui, inventory_num: &mut usize, inventory: &mut [Inve
ui.horizontal(|ui| {
for (i, inventory) in chunk.iter_mut().enumerate() {
ui.vertical(|ui| {
egui::ComboBox::new(format!("weapontype-box-{}", chunk_i * chunk_size + i), "")
let pos = chunk_i * chunk_size + i;
egui::ComboBox::new(format!("weapontype-box-{pos}"), "")
.width(150.)
.selected_text(inventory.to_string())
.show_ui(ui, |ui| {
for model in Inventory::iter() {
let mut iter = Inventory::iter();
if pos + 1 < *inventory_num {
iter.next();
}
for model in iter {
ui.selectable_value(inventory, model, model.to_string());
}
});
Expand Down
9 changes: 7 additions & 2 deletions src/app/weapon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ pub fn draw_window(ui: &mut Ui, weapon_num: &mut usize, weapon: &mut [Weapon]) {
ui.horizontal(|ui| {
for (i, weapon) in chunk.iter_mut().enumerate() {
ui.vertical(|ui| {
egui::ComboBox::new(format!("weapontype-box-{}", chunk_i * chunk_size + i), "")
let pos = chunk_i * chunk_size + i;
egui::ComboBox::new(format!("weapontype-box-{pos}"), "")
.width(150.)
.selected_text(weapon.classification.to_string())
.show_ui(ui, |ui| {
for model in WeaponType::iter() {
let mut iter = WeaponType::iter();
if pos + 1 < *weapon_num {
iter.next();
}
for model in iter {
ui.selectable_value(
&mut weapon.classification,
model,
Expand Down

0 comments on commit 8a9f137

Please sign in to comment.