mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
simplified settings changing within hud and settings_window
This commit is contained in:
parent
4503d5160c
commit
399795dbf1
@ -5,7 +5,7 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
i18n::Localization,
|
||||
session::settings_change::{Interface as InterfaceChange, SettingsChange},
|
||||
session::settings_change::{Interface as InterfaceChange, Interface::*},
|
||||
ui::{fonts::Fonts, img_ids, ImageFrame, Tooltip, TooltipManager, Tooltipable},
|
||||
GlobalState,
|
||||
};
|
||||
@ -118,15 +118,10 @@ pub struct State {
|
||||
}
|
||||
|
||||
pub enum Event {
|
||||
SettingsChange(SettingsChange),
|
||||
SettingsChange(InterfaceChange),
|
||||
Close,
|
||||
RequestSiteInfo(SiteId),
|
||||
}
|
||||
impl From<InterfaceChange> for Event {
|
||||
fn from(interface_change: InterfaceChange) -> Self {
|
||||
Event::SettingsChange(interface_change.into())
|
||||
}
|
||||
}
|
||||
|
||||
fn get_site_economy(site_rich: &SiteInfoRich) -> String {
|
||||
if SHOW_ECONOMY {
|
||||
@ -313,7 +308,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.sum();
|
||||
// Drag represents offset of view from the player_pos in chunk coords
|
||||
let drag_new = drag + dragged / map_size / zoom * max_zoom;
|
||||
events.push(InterfaceChange::MapDrag(drag_new).into());
|
||||
events.push(Event::SettingsChange(MapDrag(drag_new)));
|
||||
|
||||
let rect_src = position::Rect::from_xy_dim(
|
||||
[
|
||||
@ -364,7 +359,7 @@ impl<'a> Widget for Map<'a> {
|
||||
let new_zoom_lvl = (self.global_state.settings.interface.map_zoom
|
||||
* (scrolled * 0.05 * -1.0).exp2())
|
||||
.clamped(1.25, max_zoom / 64.0);
|
||||
events.push(InterfaceChange::MapZoom(new_zoom_lvl as f64).into());
|
||||
events.push(Event::SettingsChange(MapZoom(new_zoom_lvl as f64)));
|
||||
// Icon settings
|
||||
// Alignment
|
||||
Rectangle::fill_with([150.0, 200.0], color::TRANSPARENT)
|
||||
@ -396,7 +391,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.show_difficulty_box, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::MapShowDifficulty(!show_difficulty).into());
|
||||
events.push(Event::SettingsChange(MapShowDifficulty(!show_difficulty)));
|
||||
}
|
||||
Text::new(i18n.get("hud.map.difficulty"))
|
||||
.right_from(state.ids.show_difficulty_box, 10.0)
|
||||
@ -430,7 +425,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.show_towns_box, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::MapShowTowns(!show_towns).into());
|
||||
events.push(Event::SettingsChange(MapShowTowns(!show_towns)));
|
||||
}
|
||||
Text::new(i18n.get("hud.map.towns"))
|
||||
.right_from(state.ids.show_towns_box, 10.0)
|
||||
@ -464,7 +459,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.show_castles_box, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::MapShowCastles(!show_castles).into());
|
||||
events.push(Event::SettingsChange(MapShowCastles(!show_castles)));
|
||||
}
|
||||
Text::new(i18n.get("hud.map.castles"))
|
||||
.right_from(state.ids.show_castles_box, 10.0)
|
||||
@ -498,7 +493,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.show_dungeons_box, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::MapShowDungeons(!show_dungeons).into());
|
||||
events.push(Event::SettingsChange(MapShowDungeons(!show_dungeons)));
|
||||
}
|
||||
Text::new(i18n.get("hud.map.dungeons"))
|
||||
.right_from(state.ids.show_dungeons_box, 10.0)
|
||||
@ -532,7 +527,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.show_caves_box, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::MapShowCaves(!show_caves).into());
|
||||
events.push(Event::SettingsChange(MapShowCaves(!show_caves)));
|
||||
}
|
||||
Text::new(i18n.get("hud.map.caves"))
|
||||
.right_from(state.ids.show_caves_box, 10.0)
|
||||
@ -566,7 +561,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.show_trees_box, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::MapShowTrees(!show_trees).into());
|
||||
events.push(Event::SettingsChange(MapShowTrees(!show_trees)));
|
||||
}
|
||||
Text::new(i18n.get("hud.map.trees"))
|
||||
.right_from(state.ids.show_trees_box, 10.0)
|
||||
@ -896,7 +891,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.recenter_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::MapDrag(Vec2::zero()).into());
|
||||
events.push(Event::SettingsChange(MapDrag(Vec2::zero())));
|
||||
};
|
||||
|
||||
Image::new(self.imgs.m_move_ico)
|
||||
@ -940,7 +935,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.map_mode_btn, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::MapShowTopoMap(!show_topo_map).into());
|
||||
events.push(Event::SettingsChange(MapShowTopoMap(!show_topo_map)));
|
||||
};
|
||||
Button::image(self.imgs.map_mode_overlay)
|
||||
.w_h(92.0, icon_size.y)
|
||||
|
@ -2630,7 +2630,7 @@ impl Hud {
|
||||
self.force_ungrab = false;
|
||||
},
|
||||
map::Event::SettingsChange(settings_change) => {
|
||||
events.push(Event::SettingsChange(settings_change));
|
||||
events.push(Event::SettingsChange(settings_change.into()));
|
||||
},
|
||||
map::Event::RequestSiteInfo(id) => {
|
||||
events.push(Event::RequestSiteInfo(id));
|
||||
|
@ -3,7 +3,7 @@ use super::{RESET_BUTTONS_HEIGHT, RESET_BUTTONS_WIDTH};
|
||||
use crate::{
|
||||
hud::{img_ids::Imgs, ERROR_COLOR, TEXT_BIND_CONFLICT_COLOR, TEXT_COLOR},
|
||||
i18n::Localization,
|
||||
session::settings_change::Control as ControlChange,
|
||||
session::settings_change::{Control as ControlChange, Control::*},
|
||||
ui::fonts::Fonts,
|
||||
window::GameInput,
|
||||
GlobalState,
|
||||
@ -168,7 +168,7 @@ impl<'a> Widget for Controls<'a> {
|
||||
.set(button_id, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(ControlChange::ChangeBinding(game_input));
|
||||
events.push(ChangeBinding(game_input));
|
||||
}
|
||||
// Set the previous id to the current one for the next cycle
|
||||
previous_element_id = Some(text_id);
|
||||
@ -189,7 +189,7 @@ impl<'a> Widget for Controls<'a> {
|
||||
.set(state.ids.reset_controls_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(ControlChange::ResetKeyBindings);
|
||||
events.push(ResetKeyBindings);
|
||||
}
|
||||
previous_element_id = Some(state.ids.reset_controls_button)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use super::{RESET_BUTTONS_HEIGHT, RESET_BUTTONS_WIDTH};
|
||||
use crate::{
|
||||
hud::{img_ids::Imgs, PressBehavior, MENU_BG, TEXT_COLOR},
|
||||
i18n::Localization,
|
||||
session::settings_change::Gameplay as GameplayChange,
|
||||
session::settings_change::{Gameplay as GameplayChange, Gameplay::*},
|
||||
ui::{fonts::Fonts, ImageSlider, ToggleButton},
|
||||
GlobalState,
|
||||
};
|
||||
@ -141,7 +141,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.mouse_pan_slider, ui)
|
||||
{
|
||||
events.push(GameplayChange::AdjustMousePan(new_val));
|
||||
events.push(AdjustMousePan(new_val));
|
||||
}
|
||||
|
||||
Text::new(&format!("{}", display_pan))
|
||||
@ -173,7 +173,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.mouse_zoom_slider, ui)
|
||||
{
|
||||
events.push(GameplayChange::AdjustMouseZoom(new_val));
|
||||
events.push(AdjustMouseZoom(new_val));
|
||||
}
|
||||
|
||||
Text::new(&format!("{}", display_zoom))
|
||||
@ -209,7 +209,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.camera_clamp_slider, ui)
|
||||
{
|
||||
events.push(GameplayChange::AdjustCameraClamp(new_val));
|
||||
events.push(AdjustCameraClamp(new_val));
|
||||
}
|
||||
|
||||
Text::new(&format!("{}", display_clamp))
|
||||
@ -232,7 +232,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.mouse_zoom_invert_button, ui);
|
||||
|
||||
if self.global_state.settings.gameplay.zoom_inversion != zoom_inverted {
|
||||
events.push(GameplayChange::ToggleZoomInvert(
|
||||
events.push(ToggleZoomInvert(
|
||||
!self.global_state.settings.gameplay.zoom_inversion,
|
||||
));
|
||||
}
|
||||
@ -262,7 +262,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.mouse_y_invert_button, ui);
|
||||
|
||||
if self.global_state.settings.gameplay.mouse_y_inversion != mouse_y_inverted {
|
||||
events.push(GameplayChange::ToggleMouseYInvert(
|
||||
events.push(ToggleMouseYInvert(
|
||||
!self.global_state.settings.gameplay.mouse_y_inversion,
|
||||
));
|
||||
}
|
||||
@ -292,7 +292,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.controller_y_invert_button, ui);
|
||||
|
||||
if self.global_state.settings.controller.pan_invert_y != controller_y_inverted {
|
||||
events.push(GameplayChange::ToggleControllerYInvert(
|
||||
events.push(ToggleControllerYInvert(
|
||||
!self.global_state.settings.controller.pan_invert_y,
|
||||
));
|
||||
}
|
||||
@ -322,7 +322,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.smooth_pan_toggle_button, ui);
|
||||
|
||||
if self.global_state.settings.gameplay.smooth_pan_enable != smooth_pan_enabled {
|
||||
events.push(GameplayChange::ToggleSmoothPan(
|
||||
events.push(ToggleSmoothPan(
|
||||
!self.global_state.settings.gameplay.smooth_pan_enable,
|
||||
));
|
||||
}
|
||||
@ -372,10 +372,8 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.free_look_behavior_list, ui)
|
||||
{
|
||||
match clicked {
|
||||
0 => events.push(GameplayChange::ChangeFreeLookBehavior(
|
||||
PressBehavior::Toggle,
|
||||
)),
|
||||
1 => events.push(GameplayChange::ChangeFreeLookBehavior(PressBehavior::Hold)),
|
||||
0 => events.push(ChangeFreeLookBehavior(PressBehavior::Toggle)),
|
||||
1 => events.push(ChangeFreeLookBehavior(PressBehavior::Hold)),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@ -404,10 +402,8 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.auto_walk_behavior_list, ui)
|
||||
{
|
||||
match clicked {
|
||||
0 => events.push(GameplayChange::ChangeAutoWalkBehavior(
|
||||
PressBehavior::Toggle,
|
||||
)),
|
||||
1 => events.push(GameplayChange::ChangeAutoWalkBehavior(PressBehavior::Hold)),
|
||||
0 => events.push(ChangeAutoWalkBehavior(PressBehavior::Toggle)),
|
||||
1 => events.push(ChangeAutoWalkBehavior(PressBehavior::Hold)),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@ -436,12 +432,8 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.camera_clamp_behavior_list, ui)
|
||||
{
|
||||
match clicked {
|
||||
0 => events.push(GameplayChange::ChangeCameraClampBehavior(
|
||||
PressBehavior::Toggle,
|
||||
)),
|
||||
1 => events.push(GameplayChange::ChangeCameraClampBehavior(
|
||||
PressBehavior::Hold,
|
||||
)),
|
||||
0 => events.push(ChangeCameraClampBehavior(PressBehavior::Toggle)),
|
||||
1 => events.push(ChangeCameraClampBehavior(PressBehavior::Hold)),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@ -461,7 +453,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
if self.global_state.settings.gameplay.stop_auto_walk_on_input
|
||||
!= stop_auto_walk_on_input_toggle
|
||||
{
|
||||
events.push(GameplayChange::ChangeStopAutoWalkOnInput(
|
||||
events.push(ChangeStopAutoWalkOnInput(
|
||||
!self.global_state.settings.gameplay.stop_auto_walk_on_input,
|
||||
));
|
||||
}
|
||||
@ -491,7 +483,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.auto_camera_button, ui);
|
||||
|
||||
if self.global_state.settings.gameplay.auto_camera != auto_camera_toggle {
|
||||
events.push(GameplayChange::ChangeAutoCamera(
|
||||
events.push(ChangeAutoCamera(
|
||||
!self.global_state.settings.gameplay.auto_camera,
|
||||
));
|
||||
}
|
||||
@ -518,7 +510,7 @@ impl<'a> Widget for Gameplay<'a> {
|
||||
.set(state.ids.reset_gameplay_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(GameplayChange::ResetGameplaySettings);
|
||||
events.push(ResetGameplaySettings);
|
||||
}
|
||||
|
||||
events
|
||||
|
@ -5,7 +5,7 @@ use crate::{
|
||||
img_ids::Imgs, BarNumbers, BuffPosition, CrosshairType, ShortcutNumbers, Show, TEXT_COLOR,
|
||||
},
|
||||
i18n::Localization,
|
||||
session::settings_change::Interface as InterfaceChange,
|
||||
session::settings_change::{Interface as InterfaceChange, Interface::*},
|
||||
ui::{fonts::Fonts, ImageSlider, ScaleMode, ToggleButton},
|
||||
GlobalState,
|
||||
};
|
||||
@ -186,7 +186,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.button_help, ui);
|
||||
|
||||
if self.show.help != show_help {
|
||||
events.push(InterfaceChange::ToggleHelp(show_help));
|
||||
events.push(ToggleHelp(show_help));
|
||||
}
|
||||
|
||||
Text::new(&self.localized_strings.get("hud.settings.help_window"))
|
||||
@ -210,7 +210,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.load_tips_button, ui);
|
||||
|
||||
if self.global_state.settings.interface.loading_tips != show_tips {
|
||||
events.push(InterfaceChange::ToggleTips(
|
||||
events.push(ToggleTips(
|
||||
!self.global_state.settings.interface.loading_tips,
|
||||
));
|
||||
}
|
||||
@ -235,7 +235,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.debug_button, ui);
|
||||
|
||||
if self.show.debug != show_debug {
|
||||
events.push(InterfaceChange::ToggleDebug(show_debug));
|
||||
events.push(ToggleDebug(show_debug));
|
||||
}
|
||||
|
||||
Text::new(&self.localized_strings.get("hud.settings.debug_info"))
|
||||
@ -278,7 +278,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.was_clicked()
|
||||
&& !relative_selected
|
||||
{
|
||||
events.push(InterfaceChange::UiScale(ScaleChange::ToRelative));
|
||||
events.push(UiScale(ScaleChange::ToRelative));
|
||||
}
|
||||
|
||||
Text::new(self.localized_strings.get("hud.settings.relative_scaling"))
|
||||
@ -313,7 +313,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.was_clicked()
|
||||
&& !absolute_selected
|
||||
{
|
||||
events.push(InterfaceChange::UiScale(ScaleChange::ToAbsolute));
|
||||
events.push(UiScale(ScaleChange::ToAbsolute));
|
||||
}
|
||||
|
||||
Text::new(self.localized_strings.get("hud.settings.custom_scaling"))
|
||||
@ -340,9 +340,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.ui_scale_slider, ui)
|
||||
{
|
||||
events.push(InterfaceChange::UiScale(ScaleChange::Adjust(
|
||||
2.0f64.powf(new_val),
|
||||
)));
|
||||
events.push(UiScale(ScaleChange::Adjust(2.0f64.powf(new_val))));
|
||||
}
|
||||
// Custom Scaling Text
|
||||
Text::new(&format!("{:.2}", scale))
|
||||
@ -387,7 +385,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.ch_1_bg, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::CrosshairType(CrosshairType::Round));
|
||||
events.push(CrosshairType(CrosshairType::Round));
|
||||
}
|
||||
|
||||
// Crosshair
|
||||
@ -430,7 +428,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.ch_2_bg, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::CrosshairType(CrosshairType::RoundEdges));
|
||||
events.push(CrosshairType(CrosshairType::RoundEdges));
|
||||
}
|
||||
|
||||
// Crosshair
|
||||
@ -473,7 +471,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.ch_3_bg, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::CrosshairType(CrosshairType::Edges));
|
||||
events.push(CrosshairType(CrosshairType::Edges));
|
||||
}
|
||||
|
||||
// Crosshair
|
||||
@ -522,7 +520,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.ch_transp_slider, ui)
|
||||
{
|
||||
events.push(InterfaceChange::CrosshairTransp(new_val));
|
||||
events.push(CrosshairTransp(new_val));
|
||||
}
|
||||
|
||||
Text::new(&format!("{:.2}", crosshair_transp,))
|
||||
@ -565,12 +563,8 @@ impl<'a> Widget for Interface<'a> {
|
||||
.was_clicked()
|
||||
{
|
||||
match self.global_state.settings.interface.shortcut_numbers {
|
||||
ShortcutNumbers::On => {
|
||||
events.push(InterfaceChange::ToggleShortcutNumbers(ShortcutNumbers::Off))
|
||||
},
|
||||
ShortcutNumbers::Off => {
|
||||
events.push(InterfaceChange::ToggleShortcutNumbers(ShortcutNumbers::On))
|
||||
},
|
||||
ShortcutNumbers::On => events.push(ToggleShortcutNumbers(ShortcutNumbers::Off)),
|
||||
ShortcutNumbers::Off => events.push(ToggleShortcutNumbers(ShortcutNumbers::On)),
|
||||
}
|
||||
}
|
||||
Text::new(&self.localized_strings.get("hud.settings.toggle_shortcuts"))
|
||||
@ -599,7 +593,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.buff_pos_bar_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::BuffPosition(BuffPosition::Bar))
|
||||
events.push(BuffPosition(BuffPosition::Bar))
|
||||
}
|
||||
Text::new(&self.localized_strings.get("hud.settings.buffs_skillbar"))
|
||||
.right_from(state.ids.buff_pos_bar_button, 10.0)
|
||||
@ -626,7 +620,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.buff_pos_map_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::BuffPosition(BuffPosition::Map))
|
||||
events.push(BuffPosition(BuffPosition::Map))
|
||||
}
|
||||
Text::new(&self.localized_strings.get("hud.settings.buffs_mmap"))
|
||||
.right_from(state.ids.buff_pos_map_button, 10.0)
|
||||
@ -672,9 +666,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.sct_show_radio, ui);
|
||||
|
||||
if self.global_state.settings.interface.sct != show_sct {
|
||||
events.push(InterfaceChange::Sct(
|
||||
!self.global_state.settings.interface.sct,
|
||||
))
|
||||
events.push(Sct(!self.global_state.settings.interface.sct))
|
||||
}
|
||||
Text::new(
|
||||
&self
|
||||
@ -724,7 +716,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.sct_show_batch_radio, ui);
|
||||
|
||||
if self.global_state.settings.interface.sct_damage_batch != show_sct_damage_batch {
|
||||
events.push(InterfaceChange::SctDamageBatch(
|
||||
events.push(SctDamageBatch(
|
||||
!self.global_state.settings.interface.sct_damage_batch,
|
||||
))
|
||||
}
|
||||
@ -767,7 +759,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.sct_batch_inc_radio, ui);
|
||||
|
||||
if self.global_state.settings.interface.sct_player_batch != show_sct_player_batch {
|
||||
events.push(InterfaceChange::SctPlayerBatch(
|
||||
events.push(SctPlayerBatch(
|
||||
!self.global_state.settings.interface.sct_player_batch,
|
||||
))
|
||||
}
|
||||
@ -811,9 +803,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked)
|
||||
.set(state.ids.speech_bubble_dark_mode_button, ui);
|
||||
if self.global_state.settings.interface.speech_bubble_dark_mode != speech_bubble_dark_mode {
|
||||
events.push(InterfaceChange::SpeechBubbleDarkMode(
|
||||
speech_bubble_dark_mode,
|
||||
));
|
||||
events.push(SpeechBubbleDarkMode(speech_bubble_dark_mode));
|
||||
}
|
||||
Text::new(
|
||||
&self
|
||||
@ -837,7 +827,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked)
|
||||
.set(state.ids.speech_bubble_icon_button, ui);
|
||||
if self.global_state.settings.interface.speech_bubble_icon != speech_bubble_icon {
|
||||
events.push(InterfaceChange::SpeechBubbleIcon(speech_bubble_icon));
|
||||
events.push(SpeechBubbleIcon(speech_bubble_icon));
|
||||
}
|
||||
Text::new(
|
||||
&self
|
||||
@ -880,7 +870,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.show_bar_numbers_none_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::ToggleBarNumbers(BarNumbers::Off))
|
||||
events.push(ToggleBarNumbers(BarNumbers::Off))
|
||||
}
|
||||
Text::new(&self.localized_strings.get("hud.settings.none"))
|
||||
.right_from(state.ids.show_bar_numbers_none_button, 10.0)
|
||||
@ -911,7 +901,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.show_bar_numbers_values_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::ToggleBarNumbers(BarNumbers::Values))
|
||||
events.push(ToggleBarNumbers(BarNumbers::Values))
|
||||
}
|
||||
Text::new(&self.localized_strings.get("hud.settings.values"))
|
||||
.right_from(state.ids.show_bar_numbers_values_button, 10.0)
|
||||
@ -942,7 +932,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.show_bar_numbers_percentage_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::ToggleBarNumbers(BarNumbers::Percent))
|
||||
events.push(ToggleBarNumbers(BarNumbers::Percent))
|
||||
}
|
||||
Text::new(&self.localized_strings.get("hud.settings.percentages"))
|
||||
.right_from(state.ids.show_bar_numbers_percentage_button, 10.0)
|
||||
@ -984,7 +974,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.chat_transp_slider, ui)
|
||||
{
|
||||
events.push(InterfaceChange::ChatTransp(new_val));
|
||||
events.push(ChatTransp(new_val));
|
||||
}
|
||||
|
||||
// "Show character names in chat" toggle button
|
||||
@ -999,7 +989,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.press_images(self.imgs.checkbox_press, self.imgs.checkbox_checked)
|
||||
.set(state.ids.chat_char_name_button, ui);
|
||||
if self.global_state.settings.interface.chat_character_name != chat_char_name {
|
||||
events.push(InterfaceChange::ChatCharName(
|
||||
events.push(ChatCharName(
|
||||
!self.global_state.settings.interface.chat_character_name,
|
||||
));
|
||||
}
|
||||
@ -1030,7 +1020,7 @@ impl<'a> Widget for Interface<'a> {
|
||||
.set(state.ids.reset_interface_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(InterfaceChange::ResetInterfaceSettings);
|
||||
events.push(ResetInterfaceSettings);
|
||||
}
|
||||
|
||||
events
|
||||
|
@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
hud::{img_ids::Imgs, TEXT_COLOR},
|
||||
i18n::list_localizations,
|
||||
session::settings_change::Language as LanguageChange,
|
||||
session::settings_change::{Language as LanguageChange, Language::*},
|
||||
ui::fonts::Fonts,
|
||||
GlobalState,
|
||||
};
|
||||
@ -113,9 +113,7 @@ impl<'a> Widget for Language<'a> {
|
||||
.set(state.ids.language_list[i], ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(LanguageChange::ChangeLanguage(Box::new(
|
||||
language.to_owned(),
|
||||
)));
|
||||
events.push(ChangeLanguage(Box::new(language.to_owned())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ use super::{RESET_BUTTONS_HEIGHT, RESET_BUTTONS_WIDTH};
|
||||
use crate::{
|
||||
hud::{img_ids::Imgs, TEXT_COLOR},
|
||||
i18n::Localization,
|
||||
session::settings_change::Audio as AudioChange,
|
||||
session::settings_change::{Audio as AudioChange, Audio::*},
|
||||
ui::{fonts::Fonts, ImageSlider},
|
||||
GlobalState,
|
||||
};
|
||||
@ -115,7 +115,7 @@ impl<'a> Widget for Sound<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.audio_volume_slider, ui)
|
||||
{
|
||||
events.push(AudioChange::AdjustMusicVolume(new_val));
|
||||
events.push(AdjustMusicVolume(new_val));
|
||||
}
|
||||
|
||||
// SFX Volume -------------------------------------------------------
|
||||
@ -144,7 +144,7 @@ impl<'a> Widget for Sound<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.sfx_volume_slider, ui)
|
||||
{
|
||||
events.push(AudioChange::AdjustSfxVolume(new_val));
|
||||
events.push(AdjustSfxVolume(new_val));
|
||||
}
|
||||
|
||||
// Audio Device Selector
|
||||
@ -171,7 +171,7 @@ impl<'a> Widget for Sound<'a> {
|
||||
// .set(state.ids.audio_device_list, ui)
|
||||
//{
|
||||
// let new_val = device_list[clicked].clone();
|
||||
// events.push(AudioChange::ChangeAudioDevice(new_val));
|
||||
// events.push(ChangeAudioDevice(new_val));
|
||||
//}
|
||||
|
||||
// Reset the sound settings to the default settings
|
||||
@ -188,7 +188,7 @@ impl<'a> Widget for Sound<'a> {
|
||||
.set(state.ids.reset_sound_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(AudioChange::ResetAudioSettings);
|
||||
events.push(ResetAudioSettings);
|
||||
}
|
||||
|
||||
events
|
||||
|
@ -10,7 +10,7 @@ use crate::{
|
||||
AaMode, CloudMode, FluidMode, LightingMode, RenderMode, ShadowMapMode, ShadowMode,
|
||||
UpscaleMode,
|
||||
},
|
||||
session::settings_change::Graphics as GraphicsChange,
|
||||
session::settings_change::{Graphics as GraphicsChange, Graphics::*},
|
||||
settings::Fps,
|
||||
ui::{fonts::Fonts, ImageSlider, ToggleButton},
|
||||
window::{FullScreenSettings, FullscreenMode},
|
||||
@ -227,7 +227,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.vd_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::AdjustViewDistance(new_val));
|
||||
events.push(AdjustViewDistance(new_val));
|
||||
}
|
||||
|
||||
Text::new(&format!(
|
||||
@ -265,7 +265,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.max_fps_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeMaxFPS(FPS_CHOICES[which]));
|
||||
events.push(ChangeMaxFPS(FPS_CHOICES[which]));
|
||||
}
|
||||
|
||||
Text::new(&self.global_state.settings.graphics.max_fps.to_string())
|
||||
@ -297,7 +297,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.fov_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeFOV(new_val));
|
||||
events.push(ChangeFOV(new_val));
|
||||
}
|
||||
|
||||
Text::new(&format!("{}", self.global_state.settings.graphics.fov))
|
||||
@ -330,7 +330,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.lod_detail_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::AdjustLodDetail(
|
||||
events.push(AdjustLodDetail(
|
||||
(5.0f32.powf(new_val as f32 / 10.0) * 100.0) as u32,
|
||||
));
|
||||
}
|
||||
@ -367,9 +367,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.gamma_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeGamma(
|
||||
2.0f32.powf(new_val as f32 / 8.0),
|
||||
));
|
||||
events.push(ChangeGamma(2.0f32.powf(new_val as f32 / 8.0)));
|
||||
}
|
||||
|
||||
Text::new(&format!("{:.2}", self.global_state.settings.graphics.gamma))
|
||||
@ -394,7 +392,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.exposure_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeExposure(new_val as f32 / 16.0));
|
||||
events.push(ChangeExposure(new_val as f32 / 16.0));
|
||||
}
|
||||
|
||||
Text::new(&self.localized_strings.get("hud.settings.exposure"))
|
||||
@ -432,7 +430,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.ambiance_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeAmbiance(new_val as f32));
|
||||
events.push(ChangeAmbiance(new_val as f32));
|
||||
}
|
||||
Text::new(&self.localized_strings.get("hud.settings.ambiance"))
|
||||
.up_from(state.ids.ambiance_slider, 8.0)
|
||||
@ -468,7 +466,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.sprite_dist_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::AdjustSpriteRenderDistance(new_val));
|
||||
events.push(AdjustSpriteRenderDistance(new_val));
|
||||
}
|
||||
Text::new(
|
||||
&self
|
||||
@ -508,7 +506,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.figure_dist_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::AdjustFigureLoDRenderDistance(new_val));
|
||||
events.push(AdjustFigureLoDRenderDistance(new_val));
|
||||
}
|
||||
Text::new(
|
||||
&self
|
||||
@ -572,7 +570,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.down_from(state.ids.aa_mode_text, 8.0)
|
||||
.set(state.ids.aa_mode_list, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
events.push(ChangeRenderMode(Box::new(RenderMode {
|
||||
aa: mode_list[clicked],
|
||||
..render_mode.clone()
|
||||
})));
|
||||
@ -612,7 +610,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.down_from(state.ids.upscale_factor_text, 8.0)
|
||||
.set(state.ids.upscale_factor_list, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
events.push(ChangeRenderMode(Box::new(RenderMode {
|
||||
upscale_mode: UpscaleMode {
|
||||
factor: upscale_factors[clicked],
|
||||
},
|
||||
@ -670,7 +668,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.down_from(state.ids.cloud_mode_text, 8.0)
|
||||
.set(state.ids.cloud_mode_list, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
events.push(ChangeRenderMode(Box::new(RenderMode {
|
||||
cloud: mode_list[clicked],
|
||||
..render_mode.clone()
|
||||
})));
|
||||
@ -709,7 +707,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.down_from(state.ids.fluid_mode_text, 8.0)
|
||||
.set(state.ids.fluid_mode_list, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
events.push(ChangeRenderMode(Box::new(RenderMode {
|
||||
fluid: mode_list[clicked],
|
||||
..render_mode.clone()
|
||||
})));
|
||||
@ -755,7 +753,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.down_from(state.ids.lighting_mode_text, 8.0)
|
||||
.set(state.ids.lighting_mode_list, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
events.push(ChangeRenderMode(Box::new(RenderMode {
|
||||
lighting: mode_list[clicked],
|
||||
..render_mode.clone()
|
||||
})));
|
||||
@ -802,7 +800,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.down_from(state.ids.shadow_mode_text, 8.0)
|
||||
.set(state.ids.shadow_mode_list, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
events.push(ChangeRenderMode(Box::new(RenderMode {
|
||||
shadow: mode_list[clicked],
|
||||
..render_mode.clone()
|
||||
})));
|
||||
@ -835,7 +833,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.shadow_mode_map_resolution_slider, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeRenderMode(Box::new(RenderMode {
|
||||
events.push(ChangeRenderMode(Box::new(RenderMode {
|
||||
shadow: ShadowMode::Map(ShadowMapMode {
|
||||
resolution: 2.0f32.powf(f32::from(new_val) / 4.0),
|
||||
}),
|
||||
@ -873,7 +871,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.set(state.ids.particles_button, ui);
|
||||
|
||||
if self.global_state.settings.graphics.particles_enabled != particles_enabled {
|
||||
events.push(GraphicsChange::ToggleParticlesEnabled(particles_enabled));
|
||||
events.push(ToggleParticlesEnabled(particles_enabled));
|
||||
}
|
||||
|
||||
// Resolution
|
||||
@ -910,7 +908,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.down_from(state.ids.resolution_label, 10.0)
|
||||
.set(state.ids.resolution, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeFullscreenMode(FullScreenSettings {
|
||||
events.push(ChangeFullscreenMode(FullScreenSettings {
|
||||
resolution: resolutions[clicked],
|
||||
..self.global_state.settings.graphics.fullscreen
|
||||
}));
|
||||
@ -974,7 +972,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.right_from(state.ids.resolution, 8.0)
|
||||
.set(state.ids.bit_depth, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeFullscreenMode(FullScreenSettings {
|
||||
events.push(ChangeFullscreenMode(FullScreenSettings {
|
||||
bit_depth: if clicked == 0 {
|
||||
None
|
||||
} else {
|
||||
@ -1028,7 +1026,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.right_from(state.ids.bit_depth, 8.0)
|
||||
.set(state.ids.refresh_rate, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeFullscreenMode(FullScreenSettings {
|
||||
events.push(ChangeFullscreenMode(FullScreenSettings {
|
||||
refresh_rate: if clicked == 0 {
|
||||
None
|
||||
} else {
|
||||
@ -1058,7 +1056,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.set(state.ids.fullscreen_button, ui);
|
||||
|
||||
if self.global_state.settings.graphics.fullscreen.enabled != enabled {
|
||||
events.push(GraphicsChange::ChangeFullscreenMode(FullScreenSettings {
|
||||
events.push(ChangeFullscreenMode(FullScreenSettings {
|
||||
enabled,
|
||||
..self.global_state.settings.graphics.fullscreen
|
||||
}));
|
||||
@ -1095,7 +1093,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.down_from(state.ids.fullscreen_mode_text, 8.0)
|
||||
.set(state.ids.fullscreen_mode_list, ui)
|
||||
{
|
||||
events.push(GraphicsChange::ChangeFullscreenMode(FullScreenSettings {
|
||||
events.push(ChangeFullscreenMode(FullScreenSettings {
|
||||
mode: mode_list[clicked],
|
||||
..self.global_state.settings.graphics.fullscreen
|
||||
}));
|
||||
@ -1115,7 +1113,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.set(state.ids.save_window_size_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(GraphicsChange::AdjustWindowSize(
|
||||
events.push(AdjustWindowSize(
|
||||
self.global_state
|
||||
.window
|
||||
.logical_size()
|
||||
@ -1139,7 +1137,7 @@ impl<'a> Widget for Video<'a> {
|
||||
.set(state.ids.reset_graphics_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(GraphicsChange::ResetGraphicsSettings);
|
||||
events.push(ResetGraphicsSettings);
|
||||
}
|
||||
|
||||
events
|
||||
|
Loading…
Reference in New Issue
Block a user