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 {
|
pub enum Event {
|
||||||
SendMessage(String),
|
SendMessage(String),
|
||||||
|
AdjustVd(u8),
|
||||||
Logout,
|
Logout,
|
||||||
Quit,
|
Quit,
|
||||||
}
|
}
|
||||||
@ -207,6 +208,8 @@ pub struct Hud {
|
|||||||
to_focus: Option<Option<widget::Id>>,
|
to_focus: Option<Option<widget::Id>>,
|
||||||
settings: Settings,
|
settings: Settings,
|
||||||
force_ungrab: bool,
|
force_ungrab: bool,
|
||||||
|
// TODO: move to settings
|
||||||
|
current_vd: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hud {
|
impl Hud {
|
||||||
@ -243,6 +246,7 @@ impl Hud {
|
|||||||
to_focus: None,
|
to_focus: None,
|
||||||
settings,
|
settings,
|
||||||
force_ungrab: false,
|
force_ungrab: false,
|
||||||
|
current_vd: 5,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,18 +376,21 @@ impl Hud {
|
|||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
if let Windows::Settings = self.show.open_windows {
|
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)
|
.set(self.ids.settings_window, ui_widgets)
|
||||||
{
|
{
|
||||||
Some(settings_window::Event::ToggleHelp) => self.show.toggle_help(),
|
match event {
|
||||||
Some(settings_window::Event::ToggleInventoryTestButton) => {
|
settings_window::Event::ToggleHelp => self.show.toggle_help(),
|
||||||
|
settings_window::Event::ToggleInventoryTestButton => {
|
||||||
self.show.inventory_test_button = !self.show.inventory_test_button
|
self.show.inventory_test_button = !self.show.inventory_test_button
|
||||||
}
|
}
|
||||||
Some(settings_window::Event::ToggleDebug) => self.show.debug = !self.show.debug,
|
settings_window::Event::ToggleDebug => self.show.debug = !self.show.debug,
|
||||||
Some(settings_window::Event::Close) => {
|
settings_window::Event::Close => self.show.open_windows = Windows::None,
|
||||||
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 super::{img_ids::Imgs, Fonts, TEXT_COLOR};
|
||||||
use crate::{hud::Show, ui::ToggleButton};
|
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::{
|
use crate::{
|
||||||
render::Renderer,
|
render::Renderer,
|
||||||
ui::{
|
ui::{
|
||||||
@ -14,6 +9,11 @@ use crate::{
|
|||||||
},
|
},
|
||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
|
use conrod_core::{
|
||||||
|
color,
|
||||||
|
widget::{self, Button, Image, Rectangle, Scrollbar, Text},
|
||||||
|
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
|
};
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
struct Ids {
|
struct Ids {
|
||||||
|
|
||||||
@ -62,16 +62,19 @@ pub struct SettingsWindow<'a> {
|
|||||||
imgs: &'a Imgs,
|
imgs: &'a Imgs,
|
||||||
fonts: &'a Fonts,
|
fonts: &'a Fonts,
|
||||||
|
|
||||||
|
current_vd: u8,
|
||||||
|
|
||||||
#[conrod(common_builder)]
|
#[conrod(common_builder)]
|
||||||
common: widget::CommonBuilder,
|
common: widget::CommonBuilder,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> SettingsWindow<'a> {
|
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 {
|
Self {
|
||||||
show,
|
show,
|
||||||
imgs,
|
imgs,
|
||||||
fonts,
|
fonts,
|
||||||
|
current_vd,
|
||||||
common: widget::CommonBuilder::default(),
|
common: widget::CommonBuilder::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,12 +91,13 @@ pub enum Event {
|
|||||||
ToggleInventoryTestButton,
|
ToggleInventoryTestButton,
|
||||||
ToggleDebug,
|
ToggleDebug,
|
||||||
Close,
|
Close,
|
||||||
|
AdjustVd(u8),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Widget for SettingsWindow<'a> {
|
impl<'a> Widget for SettingsWindow<'a> {
|
||||||
type State = State;
|
type State = State;
|
||||||
type Style = ();
|
type Style = ();
|
||||||
type Event = Option<Event>;
|
type Event = Vec<Event>;
|
||||||
|
|
||||||
fn init_state(&self, id_gen: widget::id::Generator) -> Self::State {
|
fn init_state(&self, id_gen: widget::id::Generator) -> Self::State {
|
||||||
State {
|
State {
|
||||||
@ -109,6 +113,8 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
||||||
let widget::UpdateArgs { state, ui, .. } = args;
|
let widget::UpdateArgs { state, ui, .. } = args;
|
||||||
|
|
||||||
|
let mut events = Vec::new();
|
||||||
|
|
||||||
// Frame Alignment
|
// Frame Alignment
|
||||||
Rectangle::fill_with([824.0, 488.0], color::TRANSPARENT)
|
Rectangle::fill_with([824.0, 488.0], color::TRANSPARENT)
|
||||||
.middle_of(ui.window)
|
.middle_of(ui.window)
|
||||||
@ -142,7 +148,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
.set(state.ids.settings_close, ui)
|
.set(state.ids.settings_close, ui)
|
||||||
.was_clicked()
|
.was_clicked()
|
||||||
{
|
{
|
||||||
return Some(Event::Close);
|
events.push(Event::Close);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
@ -190,7 +196,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
.set(state.ids.button_help, ui);
|
.set(state.ids.button_help, ui);
|
||||||
|
|
||||||
if self.show.help != show_help {
|
if self.show.help != show_help {
|
||||||
return Some(Event::ToggleHelp);
|
events.push(Event::ToggleHelp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Text::new("Show Help")
|
Text::new("Show Help")
|
||||||
@ -214,7 +220,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
.set(state.ids.inventory_test_button, ui);
|
.set(state.ids.inventory_test_button, ui);
|
||||||
|
|
||||||
if self.show.inventory_test_button != inventory_test_button {
|
if self.show.inventory_test_button != inventory_test_button {
|
||||||
return Some(Event::ToggleInventoryTestButton);
|
events.push(Event::ToggleInventoryTestButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
Text::new("Show Inventory Test Button")
|
Text::new("Show Inventory Test Button")
|
||||||
@ -235,7 +241,7 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
.set(state.ids.debug_button, ui);
|
.set(state.ids.debug_button, ui);
|
||||||
|
|
||||||
if self.show.debug != show_debug {
|
if self.show.debug != show_debug {
|
||||||
return Some(Event::ToggleDebug);
|
events.push(Event::ToggleDebug);
|
||||||
}
|
}
|
||||||
|
|
||||||
Text::new("Show Debug Window")
|
Text::new("Show Debug Window")
|
||||||
@ -469,18 +475,22 @@ impl<'a> Widget for SettingsWindow<'a> {
|
|||||||
.color(TEXT_COLOR)
|
.color(TEXT_COLOR)
|
||||||
.set(state.ids.vd_slider_text, ui);
|
.set(state.ids.vd_slider_text, ui);
|
||||||
|
|
||||||
if let Some(new_val) = ImageSlider::continuous(5.0,
|
if let Some(new_val) = ImageSlider::discrete(
|
||||||
5.0,
|
self.current_vd,
|
||||||
25.0,
|
1,
|
||||||
|
25,
|
||||||
self.imgs.slider_indicator,
|
self.imgs.slider_indicator,
|
||||||
self.imgs.slider,)
|
self.imgs.slider,
|
||||||
.w_h(208.0, 22.0)
|
)
|
||||||
|
.w_h(104.0, 22.0)
|
||||||
.down_from(state.ids.vd_slider_text, 10.0)
|
.down_from(state.ids.vd_slider_text, 10.0)
|
||||||
.track_breadth(12.0)
|
.track_breadth(12.0)
|
||||||
.slider_length(10.0)
|
.slider_length(10.0)
|
||||||
.pad_track((5.0, 5.0))
|
.pad_track((5.0, 5.0))
|
||||||
.set(state.ids.vd_slider, ui)
|
.set(state.ids.vd_slider, ui)
|
||||||
{}
|
{
|
||||||
|
events.push(Event::AdjustVd(new_val));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 5 Sound
|
// 5 Sound
|
||||||
if Button::image(if let SettingsTab::Sound = state.settings_tab {
|
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);
|
state.update(|s| s.settings_tab = SettingsTab::Sound);
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
events
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,10 @@ impl PlayState for SessionState {
|
|||||||
HudEvent::Quit => {
|
HudEvent::Quit => {
|
||||||
return PlayStateResult::Shutdown;
|
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