mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Pass up Vd slider changes to session.rs & fmt
Former-commit-id: 187a3d286e288d2159fcde292f78e2bc08ec796b
This commit is contained in:
parent
78173b4bce
commit
0349461533
@ -90,6 +90,7 @@ font_ids! {
|
||||
|
||||
pub enum Event {
|
||||
SendMessage(String),
|
||||
AdjustVd(u8),
|
||||
Logout,
|
||||
Quit,
|
||||
}
|
||||
@ -207,6 +208,8 @@ pub struct Hud {
|
||||
to_focus: Option<Option<widget::Id>>,
|
||||
settings: Settings,
|
||||
force_ungrab: bool,
|
||||
// TODO: move to settings
|
||||
current_vd: u8,
|
||||
}
|
||||
|
||||
impl Hud {
|
||||
@ -243,6 +246,7 @@ impl Hud {
|
||||
to_focus: None,
|
||||
settings,
|
||||
force_ungrab: false,
|
||||
current_vd: 5,
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,18 +376,21 @@ impl Hud {
|
||||
|
||||
// Settings
|
||||
if let Windows::Settings = self.show.open_windows {
|
||||
match SettingsWindow::new(&self.show, &self.imgs, &self.fonts)
|
||||
for event in SettingsWindow::new(&self.show, &self.imgs, &self.fonts, self.current_vd)
|
||||
.set(self.ids.settings_window, ui_widgets)
|
||||
{
|
||||
Some(settings_window::Event::ToggleHelp) => self.show.toggle_help(),
|
||||
Some(settings_window::Event::ToggleInventoryTestButton) => {
|
||||
match event {
|
||||
settings_window::Event::ToggleHelp => self.show.toggle_help(),
|
||||
settings_window::Event::ToggleInventoryTestButton => {
|
||||
self.show.inventory_test_button = !self.show.inventory_test_button
|
||||
}
|
||||
Some(settings_window::Event::ToggleDebug) => self.show.debug = !self.show.debug,
|
||||
Some(settings_window::Event::Close) => {
|
||||
self.show.open_windows = Windows::None;
|
||||
settings_window::Event::ToggleDebug => self.show.debug = !self.show.debug,
|
||||
settings_window::Event::Close => self.show.open_windows = Windows::None,
|
||||
settings_window::Event::AdjustVd(new_vd) => {
|
||||
self.current_vd = new_vd;
|
||||
events.push(Event::AdjustVd(new_vd));
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
use super::{img_ids::Imgs, Fonts, TEXT_COLOR};
|
||||
use crate::{hud::Show, ui::ToggleButton};
|
||||
use conrod_core::{
|
||||
color,
|
||||
widget::{self, Button, Image, Rectangle, Scrollbar, Text},
|
||||
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||
};
|
||||
use crate::{
|
||||
render::Renderer,
|
||||
ui::{
|
||||
@ -14,6 +9,11 @@ use crate::{
|
||||
},
|
||||
window::Window,
|
||||
};
|
||||
use conrod_core::{
|
||||
color,
|
||||
widget::{self, Button, Image, Rectangle, Scrollbar, Text},
|
||||
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||
};
|
||||
widget_ids! {
|
||||
struct Ids {
|
||||
|
||||
@ -62,16 +62,19 @@ pub struct SettingsWindow<'a> {
|
||||
imgs: &'a Imgs,
|
||||
fonts: &'a Fonts,
|
||||
|
||||
current_vd: u8,
|
||||
|
||||
#[conrod(common_builder)]
|
||||
common: widget::CommonBuilder,
|
||||
}
|
||||
|
||||
impl<'a> SettingsWindow<'a> {
|
||||
pub fn new(show: &'a Show, imgs: &'a Imgs, fonts: &'a Fonts) -> Self {
|
||||
pub fn new(show: &'a Show, imgs: &'a Imgs, fonts: &'a Fonts, current_vd: u8) -> Self {
|
||||
Self {
|
||||
show,
|
||||
imgs,
|
||||
fonts,
|
||||
current_vd,
|
||||
common: widget::CommonBuilder::default(),
|
||||
}
|
||||
}
|
||||
@ -88,12 +91,13 @@ pub enum Event {
|
||||
ToggleInventoryTestButton,
|
||||
ToggleDebug,
|
||||
Close,
|
||||
AdjustVd(u8),
|
||||
}
|
||||
|
||||
impl<'a> Widget for SettingsWindow<'a> {
|
||||
type State = State;
|
||||
type Style = ();
|
||||
type Event = Option<Event>;
|
||||
type Event = Vec<Event>;
|
||||
|
||||
fn init_state(&self, id_gen: widget::id::Generator) -> Self::State {
|
||||
State {
|
||||
@ -109,6 +113,8 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
||||
let widget::UpdateArgs { state, ui, .. } = args;
|
||||
|
||||
let mut events = Vec::new();
|
||||
|
||||
// Frame Alignment
|
||||
Rectangle::fill_with([824.0, 488.0], color::TRANSPARENT)
|
||||
.middle_of(ui.window)
|
||||
@ -142,7 +148,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.set(state.ids.settings_close, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
return Some(Event::Close);
|
||||
events.push(Event::Close);
|
||||
}
|
||||
|
||||
// Title
|
||||
@ -190,7 +196,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.set(state.ids.button_help, ui);
|
||||
|
||||
if self.show.help != show_help {
|
||||
return Some(Event::ToggleHelp);
|
||||
events.push(Event::ToggleHelp);
|
||||
}
|
||||
|
||||
Text::new("Show Help")
|
||||
@ -214,7 +220,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.set(state.ids.inventory_test_button, ui);
|
||||
|
||||
if self.show.inventory_test_button != inventory_test_button {
|
||||
return Some(Event::ToggleInventoryTestButton);
|
||||
events.push(Event::ToggleInventoryTestButton);
|
||||
}
|
||||
|
||||
Text::new("Show Inventory Test Button")
|
||||
@ -235,7 +241,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.set(state.ids.debug_button, ui);
|
||||
|
||||
if self.show.debug != show_debug {
|
||||
return Some(Event::ToggleDebug);
|
||||
events.push(Event::ToggleDebug);
|
||||
}
|
||||
|
||||
Text::new("Show Debug Window")
|
||||
@ -469,18 +475,22 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
.color(TEXT_COLOR)
|
||||
.set(state.ids.vd_slider_text, ui);
|
||||
|
||||
if let Some(new_val) = ImageSlider::continuous(5.0,
|
||||
5.0,
|
||||
25.0,
|
||||
if let Some(new_val) = ImageSlider::discrete(
|
||||
self.current_vd,
|
||||
1,
|
||||
25,
|
||||
self.imgs.slider_indicator,
|
||||
self.imgs.slider,)
|
||||
.w_h(208.0, 22.0)
|
||||
self.imgs.slider,
|
||||
)
|
||||
.w_h(104.0, 22.0)
|
||||
.down_from(state.ids.vd_slider_text, 10.0)
|
||||
.track_breadth(12.0)
|
||||
.slider_length(10.0)
|
||||
.pad_track((5.0, 5.0))
|
||||
.set(state.ids.vd_slider, ui)
|
||||
{}
|
||||
{
|
||||
events.push(Event::AdjustVd(new_val));
|
||||
}
|
||||
}
|
||||
// 5 Sound
|
||||
if Button::image(if let SettingsTab::Sound = state.settings_tab {
|
||||
@ -510,6 +520,6 @@ impl<'a> Widget for SettingsWindow<'a> {
|
||||
state.update(|s| s.settings_tab = SettingsTab::Sound);
|
||||
}
|
||||
|
||||
None
|
||||
events
|
||||
}
|
||||
}
|
||||
|
@ -190,6 +190,10 @@ impl PlayState for SessionState {
|
||||
HudEvent::Quit => {
|
||||
return PlayStateResult::Shutdown;
|
||||
}
|
||||
HudEvent::AdjustVd(new_vd) => {
|
||||
println!("New VD is {}, TODO: Actually change VD", new_vd);
|
||||
//self.client.borrow_mut().set_vd(new_vd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user