mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Crosshair transp slider
This commit is contained in:
parent
3be2951029
commit
94acd0f437
@ -10,6 +10,7 @@ mod settings_window;
|
|||||||
mod skillbar;
|
mod skillbar;
|
||||||
mod small_window;
|
mod small_window;
|
||||||
|
|
||||||
|
use crate::hud::Event::CrosshairTransp;
|
||||||
use bag::Bag;
|
use bag::Bag;
|
||||||
use buttons::Buttons;
|
use buttons::Buttons;
|
||||||
use character_window::CharacterWindow;
|
use character_window::CharacterWindow;
|
||||||
@ -122,6 +123,7 @@ pub enum Event {
|
|||||||
AdjustVolume(f32),
|
AdjustVolume(f32),
|
||||||
ChangeAudioDevice(String),
|
ChangeAudioDevice(String),
|
||||||
ChangeMaxFPS(u32),
|
ChangeMaxFPS(u32),
|
||||||
|
CrosshairTransp(f32),
|
||||||
CharacterSelection,
|
CharacterSelection,
|
||||||
Logout,
|
Logout,
|
||||||
Quit,
|
Quit,
|
||||||
@ -258,6 +260,7 @@ pub struct Hud {
|
|||||||
fonts: Fonts,
|
fonts: Fonts,
|
||||||
new_messages: VecDeque<String>,
|
new_messages: VecDeque<String>,
|
||||||
inventory_space: usize,
|
inventory_space: usize,
|
||||||
|
crosshair_transp: f32,
|
||||||
show: Show,
|
show: Show,
|
||||||
to_focus: Option<Option<widget::Id>>,
|
to_focus: Option<Option<widget::Id>>,
|
||||||
force_ungrab: bool,
|
force_ungrab: bool,
|
||||||
@ -284,6 +287,7 @@ impl Hud {
|
|||||||
ids,
|
ids,
|
||||||
new_messages: VecDeque::new(),
|
new_messages: VecDeque::new(),
|
||||||
inventory_space: 8,
|
inventory_space: 8,
|
||||||
|
crosshair_transp: 0.6,
|
||||||
show: Show {
|
show: Show {
|
||||||
help: false,
|
help: false,
|
||||||
debug: true,
|
debug: true,
|
||||||
@ -340,10 +344,11 @@ impl Hud {
|
|||||||
let mut health_back_id_walker = self.ids.health_bar_backs.walk();
|
let mut health_back_id_walker = self.ids.health_bar_backs.walk();
|
||||||
|
|
||||||
// Crosshair
|
// Crosshair
|
||||||
|
let crosshair_transp = self.crosshair_transp;
|
||||||
Image::new(self.imgs.crosshair_outer)
|
Image::new(self.imgs.crosshair_outer)
|
||||||
.w_h(21.0 * 1.5, 21.0 * 1.5)
|
.w_h(21.0 * 1.5, 21.0 * 1.5)
|
||||||
.middle_of(ui_widgets.window)
|
.middle_of(ui_widgets.window)
|
||||||
.color(Some(Color::Rgba(1.0, 1.0, 1.0, 0.2)))
|
.color(Some(Color::Rgba(1.0, 1.0, 1.0, self.crosshair_transp)))
|
||||||
.set(self.ids.crosshair_outer, ui_widgets);
|
.set(self.ids.crosshair_outer, ui_widgets);
|
||||||
Image::new(self.imgs.crosshair_inner)
|
Image::new(self.imgs.crosshair_inner)
|
||||||
.w_h(21.0 * 2.0, 21.0 * 2.0)
|
.w_h(21.0 * 2.0, 21.0 * 2.0)
|
||||||
@ -624,6 +629,9 @@ impl Hud {
|
|||||||
settings_window::Event::AdjustViewDistance(view_distance) => {
|
settings_window::Event::AdjustViewDistance(view_distance) => {
|
||||||
events.push(Event::AdjustViewDistance(view_distance));
|
events.push(Event::AdjustViewDistance(view_distance));
|
||||||
}
|
}
|
||||||
|
settings_window::Event::CrosshairTransp(crosshair_transp) => {
|
||||||
|
events.push(Event::CrosshairTransp(crosshair_transp));
|
||||||
|
}
|
||||||
settings_window::Event::AdjustVolume(volume) => {
|
settings_window::Event::AdjustVolume(volume) => {
|
||||||
events.push(Event::AdjustVolume(volume));
|
events.push(Event::AdjustVolume(volume));
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,10 @@ widget_ids! {
|
|||||||
mouse_zoom_slider,
|
mouse_zoom_slider,
|
||||||
mouse_zoom_label,
|
mouse_zoom_label,
|
||||||
mouse_zoom_value,
|
mouse_zoom_value,
|
||||||
|
ch_transp_slider,
|
||||||
|
ch_transp_label,
|
||||||
|
ch_transp_value,
|
||||||
|
ch_transp_text,
|
||||||
settings_bg,
|
settings_bg,
|
||||||
sound,
|
sound,
|
||||||
test,
|
test,
|
||||||
@ -113,6 +117,7 @@ pub enum Event {
|
|||||||
AdjustVolume(f32),
|
AdjustVolume(f32),
|
||||||
ChangeAudioDevice(String),
|
ChangeAudioDevice(String),
|
||||||
MaximumFPS(u32),
|
MaximumFPS(u32),
|
||||||
|
CrosshairTransp(f32),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Widget for SettingsWindow<'a> {
|
impl<'a> Widget for SettingsWindow<'a> {
|
||||||
@ -305,6 +310,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
if let SettingsTab::Gameplay = self.show.settings_tab {
|
if let SettingsTab::Gameplay = self.show.settings_tab {
|
||||||
let display_pan = self.global_state.settings.gameplay.pan_sensitivity;
|
let display_pan = self.global_state.settings.gameplay.pan_sensitivity;
|
||||||
let display_zoom = self.global_state.settings.gameplay.zoom_sensitivity;
|
let display_zoom = self.global_state.settings.gameplay.zoom_sensitivity;
|
||||||
|
let crosshair_transp = self.global_state.settings.gameplay.crosshair_transp;
|
||||||
|
|
||||||
// Mouse Pan Sensitivity
|
// Mouse Pan Sensitivity
|
||||||
Text::new("Pan Sensitivity")
|
Text::new("Pan Sensitivity")
|
||||||
@ -369,6 +375,38 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
.font_id(self.fonts.opensans)
|
.font_id(self.fonts.opensans)
|
||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.mouse_zoom_value, ui);
|
.set(state.ids.mouse_zoom_value, ui);
|
||||||
|
|
||||||
|
// Crosshair Translucency
|
||||||
|
Text::new("Crosshair Transparency")
|
||||||
|
.down_from(state.ids.mouse_zoom_slider, 10.0)
|
||||||
|
.font_size(14)
|
||||||
|
.font_id(self.fonts.opensans)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(state.ids.ch_transp_text, ui);
|
||||||
|
|
||||||
|
if let Some(new_val) = ImageSlider::continuous(
|
||||||
|
crosshair_transp,
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
self.imgs.slider_indicator,
|
||||||
|
self.imgs.slider,
|
||||||
|
)
|
||||||
|
.w_h(104.0, 22.0)
|
||||||
|
.down_from(state.ids.ch_transp_text, 8.0)
|
||||||
|
.track_breadth(12.0)
|
||||||
|
.slider_length(10.0)
|
||||||
|
.pad_track((5.0, 5.0))
|
||||||
|
.set(state.ids.ch_transp_slider, ui)
|
||||||
|
{
|
||||||
|
events.push(Event::CrosshairTransp(new_val));
|
||||||
|
}
|
||||||
|
|
||||||
|
Text::new(&format!("{}", crosshair_transp,))
|
||||||
|
.right_from(state.ids.ch_transp_slider, 8.0)
|
||||||
|
.font_size(14)
|
||||||
|
.font_id(self.fonts.opensans)
|
||||||
|
.color(TEXT_COLOR)
|
||||||
|
.set(state.ids.ch_transp_value, ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3) Controls Tab --------------------------------
|
// 3) Controls Tab --------------------------------
|
||||||
|
@ -282,6 +282,13 @@ impl PlayState for SessionState {
|
|||||||
warn!("Failed to save settings: {:?}", err);
|
warn!("Failed to save settings: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HudEvent::CrosshairTransp(crosshair_transp) => {
|
||||||
|
global_state.settings.gameplay.crosshair_transp = crosshair_transp;
|
||||||
|
global_state.settings.gameplay.crosshair_transp = crosshair_transp;
|
||||||
|
if let Err(err) = global_state.settings.save_to_file() {
|
||||||
|
warn!("Failed to save settings: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
HudEvent::AdjustVolume(volume) => {
|
HudEvent::AdjustVolume(volume) => {
|
||||||
global_state.audio.model.player.set_volume(volume);
|
global_state.audio.model.player.set_volume(volume);
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ impl Default for ControlSettings {
|
|||||||
pub struct GameplaySettings {
|
pub struct GameplaySettings {
|
||||||
pub pan_sensitivity: u32,
|
pub pan_sensitivity: u32,
|
||||||
pub zoom_sensitivity: u32,
|
pub zoom_sensitivity: u32,
|
||||||
|
pub crosshair_transp: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for GameplaySettings {
|
impl Default for GameplaySettings {
|
||||||
@ -82,6 +83,7 @@ impl Default for GameplaySettings {
|
|||||||
Self {
|
Self {
|
||||||
pan_sensitivity: 100,
|
pan_sensitivity: 100,
|
||||||
zoom_sensitivity: 100,
|
zoom_sensitivity: 100,
|
||||||
|
crosshair_transp: 0.6,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user