mirror of
https://gitlab.com/veloren/veloren.git
synced 2025-07-26 05:12:29 +00:00
Toggle to show all recipes
This commit is contained in:
@ -164,3 +164,4 @@ hud-settings-reset_chat = Reset to Defaults
|
||||
hud-settings-third_party_integrations = Third-party Integrations
|
||||
hud-settings-enable_discord_integration = Enable Discord Integration
|
||||
hud-settings-subtitles = Subtitles
|
||||
hud-settings-show_all_recipes = Show All Recipes
|
||||
|
@ -5,11 +5,14 @@ use super::{
|
||||
slots::{CraftSlot, CraftSlotInfo, SlotManager},
|
||||
util, HudInfo, Show, TEXT_COLOR, TEXT_DULL_RED_COLOR, TEXT_GRAY_COLOR, UI_HIGHLIGHT_0, UI_MAIN,
|
||||
};
|
||||
use crate::ui::{
|
||||
fonts::Fonts,
|
||||
slot::{ContentSize, SlotMaker},
|
||||
ImageFrame, ItemTooltip, ItemTooltipManager, ItemTooltipable, Tooltip, TooltipManager,
|
||||
Tooltipable,
|
||||
use crate::{
|
||||
settings::Settings,
|
||||
ui::{
|
||||
fonts::Fonts,
|
||||
slot::{ContentSize, SlotMaker},
|
||||
ImageFrame, ItemTooltip, ItemTooltipManager, ItemTooltipable, Tooltip, TooltipManager,
|
||||
Tooltipable,
|
||||
},
|
||||
};
|
||||
use client::{self, Client};
|
||||
use common::{
|
||||
@ -37,6 +40,7 @@ use conrod_core::{
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use i18n::Localization;
|
||||
use itertools::Either;
|
||||
use std::{borrow::Cow, collections::BTreeMap, sync::Arc};
|
||||
use strum::{EnumIter, IntoEnumIterator};
|
||||
use tracing::{error, warn};
|
||||
@ -164,6 +168,7 @@ pub struct Crafting<'a> {
|
||||
common: widget::CommonBuilder,
|
||||
tooltip_manager: &'a mut TooltipManager,
|
||||
show: &'a mut Show,
|
||||
settings: &'a Settings,
|
||||
}
|
||||
|
||||
impl<'a> Crafting<'a> {
|
||||
@ -185,6 +190,7 @@ impl<'a> Crafting<'a> {
|
||||
msm: &'a MaterialStatManifest,
|
||||
tooltip_manager: &'a mut TooltipManager,
|
||||
show: &'a mut Show,
|
||||
settings: &'a Settings,
|
||||
) -> Self {
|
||||
Self {
|
||||
client,
|
||||
@ -204,6 +210,7 @@ impl<'a> Crafting<'a> {
|
||||
msm,
|
||||
show,
|
||||
common: widget::CommonBuilder::default(),
|
||||
settings,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -671,9 +678,12 @@ impl<'a> Widget for Crafting<'a> {
|
||||
|| content_contains(&name_key, substring)
|
||||
})
|
||||
};
|
||||
let mut ordered_recipes: Vec<_> = self
|
||||
.inventory
|
||||
.available_recipes_iter(self.rbm)
|
||||
let recipe_source = if self.settings.gameplay.show_all_recipes {
|
||||
Either::Left(self.rbm.iter())
|
||||
} else {
|
||||
Either::Right(self.inventory.available_recipes_iter(self.rbm))
|
||||
};
|
||||
let mut ordered_recipes: Vec<_> = recipe_source
|
||||
.filter(|(_, recipe)| match search_filter {
|
||||
SearchFilter::None => {
|
||||
search(&recipe.output.0)
|
||||
@ -750,7 +760,11 @@ impl<'a> Widget for Crafting<'a> {
|
||||
});
|
||||
|
||||
// Recipe list
|
||||
let recipe_list_length = self.inventory.recipe_book_len() + pseudo_entries.len();
|
||||
let recipe_list_length = if self.settings.gameplay.show_all_recipes {
|
||||
self.rbm.iter().count()
|
||||
} else {
|
||||
self.inventory.recipe_book_len()
|
||||
} + pseudo_entries.len();
|
||||
if state.ids.recipe_list_btns.len() < recipe_list_length {
|
||||
state.update(|state| {
|
||||
state
|
||||
|
@ -3444,6 +3444,7 @@ impl Hud {
|
||||
&msm,
|
||||
tooltip_manager,
|
||||
&mut self.show,
|
||||
&global_state.settings,
|
||||
)
|
||||
.set(self.ids.crafting_window, ui_widgets)
|
||||
{
|
||||
|
@ -59,6 +59,8 @@ widget_ids! {
|
||||
bow_zoom_label,
|
||||
zoom_lock_button,
|
||||
zoom_lock_label,
|
||||
crafting_all_recipes_button,
|
||||
crafting_all_recipes_label,
|
||||
aim_offset_x_slider,
|
||||
aim_offset_x_label,
|
||||
aim_offset_x_value,
|
||||
@ -668,6 +670,36 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.zoom_lock_label, ui);
|
||||
|
||||
// Crafting show all recipes toggle
|
||||
let all_recipes_toggle = ToggleButton::new(
|
||||
self.global_state.settings.gameplay.show_all_recipes,
|
||||
self.imgs.checkbox,
|
||||
self.imgs.checkbox_checked,
|
||||
)
|
||||
.w_h(18.0, 18.0)
|
||||
.down_from(state.ids.zoom_lock_button, 8.0)
|
||||
.hover_images(self.imgs.checkbox_mo, self.imgs.checkbox_checked_mo)
|
||||
.press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked)
|
||||
.set(state.ids.crafting_all_recipes_button, ui);
|
||||
|
||||
if self.global_state.settings.gameplay.show_all_recipes != all_recipes_toggle {
|
||||
events.push(ChangeShowAllRecipes(
|
||||
!self.global_state.settings.gameplay.show_all_recipes,
|
||||
));
|
||||
}
|
||||
|
||||
Text::new(
|
||||
&self
|
||||
.localized_strings
|
||||
.get_msg("hud-settings-show_all_recipes"),
|
||||
)
|
||||
.right_from(state.ids.crafting_all_recipes_button, 10.0)
|
||||
.font_size(self.fonts.cyri.scale(14))
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.graphics_for(state.ids.crafting_all_recipes_button)
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.crafting_all_recipes_label, ui);
|
||||
|
||||
// Aim offset x
|
||||
let display_aim_offset_x = self.global_state.settings.gameplay.aim_offset_x;
|
||||
Text::new(&self.localized_strings.get_msg("hud-settings-aim_offset_x"))
|
||||
|
@ -75,6 +75,7 @@ pub enum Gameplay {
|
||||
ChangeAutoCamera(bool),
|
||||
ChangeBowZoom(bool),
|
||||
ChangeZoomLock(bool),
|
||||
ChangeShowAllRecipes(bool),
|
||||
|
||||
AdjustAimOffsetX(f32),
|
||||
AdjustAimOffsetY(f32),
|
||||
@ -442,6 +443,9 @@ impl SettingsChange {
|
||||
// Invert Mouse Y Axis
|
||||
window.mouse_y_inversion = settings.gameplay.mouse_y_inversion;
|
||||
},
|
||||
Gameplay::ChangeShowAllRecipes(state) => {
|
||||
settings.gameplay.show_all_recipes = state;
|
||||
},
|
||||
}
|
||||
},
|
||||
SettingsChange::Graphics(graphics_change) => {
|
||||
|
@ -23,6 +23,7 @@ pub struct GameplaySettings {
|
||||
pub zoom_lock: bool,
|
||||
pub aim_offset_x: f32,
|
||||
pub aim_offset_y: f32,
|
||||
pub show_all_recipes: bool,
|
||||
}
|
||||
|
||||
impl Default for GameplaySettings {
|
||||
@ -46,6 +47,7 @@ impl Default for GameplaySettings {
|
||||
zoom_lock: false,
|
||||
aim_offset_x: 0.6,
|
||||
aim_offset_y: 0.0,
|
||||
show_all_recipes: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user