-
Notifications
You must be signed in to change notification settings - Fork 2
feat(app_gui): add destruction section #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
arnaucube
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! just a couple of small suggestions
app_cli/src/lib.rs
Outdated
|
|
||
| pub async fn destroy_item(_params: &Params, _cfg: &Config, item: &PathBuf) -> anyhow::Result<()> { | ||
| // TODO: Nullify | ||
| std::fs::remove_file(item)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would you see, instead of removing file, moving it under the {}/used path, as with the items that have been used?
Since we will nullify the item as with the used items.
| // UI for the destruction of items. | ||
| pub(crate) fn ui_destroy(&mut self, ctx: &egui::Context, ui: &mut Ui) { | ||
| let mut item_to_destroy = self.destruction.item_index; | ||
| let all_items = self.all_items(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently in the dropdown menu of items to be destructed, the ones in the used_items list appear too; but those items have been already been nullified.
Maybe here we can just list the non-used items?
| let all_items = self.all_items(); | |
| let all_items = self.items.clone(); |
app_gui/src/destruction.rs
Outdated
| ui.end_row(); | ||
| }); | ||
| ui.separator(); | ||
| egui::ComboBox::from_id_salt("destroyable items") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you replace this ComboBox by a drag-n-drop droppable label so that the UI is consistent with the inputs of Crafting?
| } | ||
|
|
||
| impl App { | ||
| pub fn update_action_ui(&mut self, ctx: &egui::Context, ui: &mut Ui) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to request a minimum width of this right panel so that the predicates don't wrap (too much).
I tried to implement it and wasn't able to get it working reliably so instead I want to request the removal of the Grid which allows the panel to be resizable (so that we can resize it to avoid the wrapping of predicates):
diff --git a/app_gui/src/main.rs b/app_gui/src/main.rs
index bf47292..da9cf02 100644
--- a/app_gui/src/main.rs
+++ b/app_gui/src/main.rs
@@ -167,47 +167,43 @@ impl eframe::App for App {
impl App {
pub fn update_action_ui(&mut self, ctx: &egui::Context, ui: &mut Ui) {
- egui::Grid::new("action UI").show(ui, |ui| {
- ui.set_min_height(32.0);
- ui.vertical(|ui| {
- ui.horizontal(|ui| {
- if ui
- .selectable_label(self.selected_tab == 0, "Mine")
- .clicked()
- {
- self.crafting.selected_recipe = None;
- self.selected_tab = 0;
- }
- if ui
- .selectable_label(self.selected_tab == 1, "Craft")
- .clicked()
- {
- self.crafting.selected_recipe = None;
- self.selected_tab = 1;
- }
- if ui
- .selectable_label(self.selected_tab == 2, "Destroy")
- .clicked()
- {
- self.destruction.item_index = None;
- self.selected_tab = 2;
- }
- if ui
- .selectable_label(self.modal_new_predicates, "+ New Predicate")
- .clicked()
- {
- self.modal_new_predicates = true;
- }
- });
- ui.separator();
- match self.selected_tab {
- 0 => self.ui_produce(ctx, ui, ProductionType::Mine),
- 1 => self.ui_produce(ctx, ui, ProductionType::Craft),
- 2 => self.ui_destroy(ctx, ui),
- _ => {}
+ ui.vertical(|ui| {
+ ui.horizontal(|ui| {
+ if ui
+ .selectable_label(self.selected_tab == 0, "Mine")
+ .clicked()
+ {
+ self.crafting.selected_recipe = None;
+ self.selected_tab = 0;
+ }
+ if ui
+ .selectable_label(self.selected_tab == 1, "Craft")
+ .clicked()
+ {
+ self.crafting.selected_recipe = None;
+ self.selected_tab = 1;
+ }
+ if ui
+ .selectable_label(self.selected_tab == 2, "Destroy")
+ .clicked()
+ {
+ self.destruction.item_index = None;
+ self.selected_tab = 2;
+ }
+ if ui
+ .selectable_label(self.modal_new_predicates, "+ New Predicate")
+ .clicked()
+ {
+ self.modal_new_predicates = true;
}
});
- ui.end_row();
+ ui.separator();
+ match self.selected_tab {
+ 0 => self.ui_produce(ctx, ui, ProductionType::Mine),
+ 1 => self.ui_produce(ctx, ui, ProductionType::Craft),
+ 2 => self.ui_destroy(ctx, ui),
+ _ => {}
+ }
});
}
}
No description provided.