2019-05-08 20:25:15 +00:00
|
|
|
use super::{img_ids::Imgs, Fonts, TEXT_COLOR};
|
2019-05-07 05:40:03 +00:00
|
|
|
use crate::{hud::Show, ui::ToggleButton};
|
2019-05-18 23:22:30 +00:00
|
|
|
use crate::{
|
|
|
|
render::Renderer,
|
|
|
|
ui::{
|
|
|
|
self,
|
|
|
|
img_ids::{ImageGraphic, VoxelGraphic},
|
|
|
|
ImageSlider, ScaleMode, Ui,
|
|
|
|
},
|
|
|
|
window::Window,
|
|
|
|
};
|
2019-05-18 23:55:06 +00:00
|
|
|
use conrod_core::{
|
|
|
|
color,
|
|
|
|
widget::{self, Button, Image, Rectangle, Scrollbar, Text},
|
|
|
|
widget_ids, Colorable, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
|
|
|
};
|
2019-05-03 16:56:18 +00:00
|
|
|
widget_ids! {
|
|
|
|
struct Ids {
|
2019-05-07 05:40:03 +00:00
|
|
|
|
2019-05-04 17:29:19 +00:00
|
|
|
settings_content,
|
|
|
|
settings_icon,
|
|
|
|
settings_button_mo,
|
|
|
|
settings_close,
|
|
|
|
settings_title,
|
|
|
|
settings_r,
|
|
|
|
settings_l,
|
|
|
|
settings_scrollbar,
|
|
|
|
controls_text,
|
2019-05-07 05:40:03 +00:00
|
|
|
controls_controls,
|
2019-05-03 16:56:18 +00:00
|
|
|
button_help,
|
2019-05-04 17:29:19 +00:00
|
|
|
button_help2,
|
2019-05-07 05:40:03 +00:00
|
|
|
show_help_label,
|
2019-05-04 17:29:19 +00:00
|
|
|
gameplay,
|
2019-05-03 16:56:18 +00:00
|
|
|
controls,
|
2019-05-07 05:40:03 +00:00
|
|
|
rectangle,
|
2019-05-03 16:56:18 +00:00
|
|
|
debug_button,
|
2019-05-07 05:40:03 +00:00
|
|
|
debug_button_label,
|
2019-05-03 16:56:18 +00:00
|
|
|
interface,
|
2019-05-06 18:49:25 +00:00
|
|
|
inventory_test_button,
|
|
|
|
inventory_test_button_label,
|
2019-05-07 05:40:03 +00:00
|
|
|
settings_bg,
|
2019-05-03 16:56:18 +00:00
|
|
|
sound,
|
|
|
|
test,
|
|
|
|
video,
|
2019-05-18 23:22:30 +00:00
|
|
|
vd_slider,
|
|
|
|
vd_slider_text,
|
2019-05-03 16:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum SettingsTab {
|
|
|
|
Interface,
|
|
|
|
Video,
|
|
|
|
Sound,
|
|
|
|
Gameplay,
|
|
|
|
Controls,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(WidgetCommon)]
|
|
|
|
pub struct SettingsWindow<'a> {
|
2019-05-07 17:50:53 +00:00
|
|
|
show: &'a Show,
|
2019-05-06 18:49:25 +00:00
|
|
|
|
2019-05-03 16:56:18 +00:00
|
|
|
imgs: &'a Imgs,
|
|
|
|
fonts: &'a Fonts,
|
|
|
|
|
2019-05-19 00:45:02 +00:00
|
|
|
current_vd: u32,
|
2019-05-18 23:55:06 +00:00
|
|
|
|
2019-05-03 16:56:18 +00:00
|
|
|
#[conrod(common_builder)]
|
|
|
|
common: widget::CommonBuilder,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> SettingsWindow<'a> {
|
2019-05-19 00:45:02 +00:00
|
|
|
pub fn new(show: &'a Show, imgs: &'a Imgs, fonts: &'a Fonts, current_vd: u32) -> Self {
|
2019-05-03 16:56:18 +00:00
|
|
|
Self {
|
2019-05-06 18:49:25 +00:00
|
|
|
show,
|
2019-05-03 16:56:18 +00:00
|
|
|
imgs,
|
|
|
|
fonts,
|
2019-05-18 23:55:06 +00:00
|
|
|
current_vd,
|
2019-05-03 16:56:18 +00:00
|
|
|
common: widget::CommonBuilder::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct State {
|
|
|
|
settings_tab: SettingsTab,
|
|
|
|
|
|
|
|
ids: Ids,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum Event {
|
2019-05-07 17:50:53 +00:00
|
|
|
ToggleHelp,
|
|
|
|
ToggleInventoryTestButton,
|
|
|
|
ToggleDebug,
|
2019-05-03 16:56:18 +00:00
|
|
|
Close,
|
2019-05-19 00:45:02 +00:00
|
|
|
AdjustViewDistance(u32),
|
2019-05-03 16:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Widget for SettingsWindow<'a> {
|
|
|
|
type State = State;
|
|
|
|
type Style = ();
|
2019-05-18 23:55:06 +00:00
|
|
|
type Event = Vec<Event>;
|
2019-05-03 16:56:18 +00:00
|
|
|
|
|
|
|
fn init_state(&self, id_gen: widget::id::Generator) -> Self::State {
|
|
|
|
State {
|
|
|
|
settings_tab: SettingsTab::Interface,
|
|
|
|
ids: Ids::new(id_gen),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn style(&self) -> Self::Style {
|
|
|
|
()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
2019-05-07 05:40:03 +00:00
|
|
|
let widget::UpdateArgs { state, ui, .. } = args;
|
2019-05-03 16:56:18 +00:00
|
|
|
|
2019-05-18 23:55:06 +00:00
|
|
|
let mut events = Vec::new();
|
|
|
|
|
2019-05-04 17:29:19 +00:00
|
|
|
// Frame Alignment
|
2019-05-04 17:54:19 +00:00
|
|
|
Rectangle::fill_with([824.0, 488.0], color::TRANSPARENT)
|
|
|
|
.middle_of(ui.window)
|
|
|
|
.set(state.ids.settings_bg, ui);
|
|
|
|
// Frame
|
|
|
|
Image::new(self.imgs.settings_frame_l)
|
|
|
|
.top_left_with_margins_on(state.ids.settings_bg, 0.0, 0.0)
|
|
|
|
.w_h(412.0, 488.0)
|
|
|
|
.set(state.ids.settings_l, ui);
|
|
|
|
Image::new(self.imgs.settings_frame_r)
|
|
|
|
.right_from(state.ids.settings_l, 0.0)
|
|
|
|
.parent(state.ids.settings_bg)
|
|
|
|
.w_h(412.0, 488.0)
|
|
|
|
.set(state.ids.settings_r, ui);
|
|
|
|
// Content Alignment
|
|
|
|
Rectangle::fill_with([198.0 * 4.0, 97.0 * 4.0], color::TRANSPARENT)
|
|
|
|
.top_right_with_margins_on(state.ids.settings_r, 21.0 * 4.0, 4.0 * 4.0)
|
|
|
|
.scroll_kids()
|
|
|
|
.scroll_kids_vertically()
|
|
|
|
.set(state.ids.settings_content, ui);
|
|
|
|
Scrollbar::y_axis(state.ids.settings_content)
|
|
|
|
.thickness(5.0)
|
|
|
|
.rgba(0.33, 0.33, 0.33, 1.0)
|
|
|
|
.set(state.ids.settings_scrollbar, ui);
|
|
|
|
// X-Button
|
|
|
|
if Button::image(self.imgs.close_button)
|
|
|
|
.w_h(28.0, 28.0)
|
|
|
|
.hover_image(self.imgs.close_button_hover)
|
|
|
|
.press_image(self.imgs.close_button_press)
|
|
|
|
.top_right_with_margins_on(state.ids.settings_r, 0.0, 0.0)
|
|
|
|
.set(state.ids.settings_close, ui)
|
|
|
|
.was_clicked()
|
2019-05-03 16:56:18 +00:00
|
|
|
{
|
2019-05-18 23:55:06 +00:00
|
|
|
events.push(Event::Close);
|
2019-05-03 16:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Title
|
2019-05-04 17:54:19 +00:00
|
|
|
Text::new("Settings")
|
|
|
|
.mid_top_with_margin_on(state.ids.settings_bg, 5.0)
|
|
|
|
.font_size(14)
|
|
|
|
.color(TEXT_COLOR)
|
2019-05-07 05:40:03 +00:00
|
|
|
.set(state.ids.settings_title, ui);
|
2019-05-03 16:56:18 +00:00
|
|
|
|
|
|
|
// Interface
|
2019-05-07 05:40:03 +00:00
|
|
|
if Button::image(if let SettingsTab::Interface = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button
|
|
|
|
})
|
|
|
|
.w_h(31.0 * 4.0, 12.0 * 4.0)
|
|
|
|
.hover_image(if let SettingsTab::Interface = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_hover
|
|
|
|
})
|
|
|
|
.press_image(if let SettingsTab::Interface = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_press
|
|
|
|
})
|
|
|
|
.top_left_with_margins_on(state.ids.settings_l, 8.0 * 4.0, 2.0 * 4.0)
|
|
|
|
.label("Interface")
|
|
|
|
.label_font_size(14)
|
|
|
|
.label_color(TEXT_COLOR)
|
|
|
|
.set(state.ids.interface, ui)
|
|
|
|
.was_clicked()
|
2019-05-03 16:56:18 +00:00
|
|
|
{
|
|
|
|
state.update(|s| s.settings_tab = SettingsTab::Interface);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let SettingsTab::Interface = state.settings_tab {
|
2019-05-04 17:54:19 +00:00
|
|
|
// Help
|
|
|
|
let show_help =
|
2019-05-06 18:49:25 +00:00
|
|
|
ToggleButton::new(self.show.help, self.imgs.check, self.imgs.check_checked)
|
2019-05-03 16:56:18 +00:00
|
|
|
.w_h(288.0 / 24.0, 288.0 / 24.0)
|
2019-05-04 17:29:19 +00:00
|
|
|
.top_left_with_margins_on(state.ids.settings_content, 5.0, 5.0)
|
2019-05-03 16:56:18 +00:00
|
|
|
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
|
|
|
|
.press_images(self.imgs.check_press, self.imgs.check_press)
|
|
|
|
.set(state.ids.button_help, ui);
|
2019-05-07 05:40:03 +00:00
|
|
|
|
2019-05-06 18:49:25 +00:00
|
|
|
if self.show.help != show_help {
|
2019-05-18 23:55:06 +00:00
|
|
|
events.push(Event::ToggleHelp);
|
2019-05-04 17:54:19 +00:00
|
|
|
}
|
2019-05-03 16:56:18 +00:00
|
|
|
|
|
|
|
Text::new("Show Help")
|
|
|
|
.right_from(state.ids.button_help, 10.0)
|
|
|
|
.font_size(12)
|
|
|
|
.font_id(self.fonts.opensans)
|
|
|
|
.graphics_for(state.ids.button_help)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.ids.show_help_label, ui);
|
|
|
|
|
2019-05-04 17:54:19 +00:00
|
|
|
// Inventory test
|
2019-05-06 18:49:25 +00:00
|
|
|
let inventory_test_button = ToggleButton::new(
|
|
|
|
self.show.inventory_test_button,
|
2019-05-03 16:56:18 +00:00
|
|
|
self.imgs.check,
|
|
|
|
self.imgs.check_checked,
|
|
|
|
)
|
2019-05-07 05:40:03 +00:00
|
|
|
.w_h(288.0 / 24.0, 288.0 / 24.0)
|
|
|
|
.down_from(state.ids.button_help, 7.0)
|
|
|
|
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
|
|
|
|
.press_images(self.imgs.check_press, self.imgs.check_press)
|
|
|
|
.set(state.ids.inventory_test_button, ui);
|
2019-05-03 16:56:18 +00:00
|
|
|
|
2019-05-06 18:49:25 +00:00
|
|
|
if self.show.inventory_test_button != inventory_test_button {
|
2019-05-18 23:55:06 +00:00
|
|
|
events.push(Event::ToggleInventoryTestButton);
|
2019-05-04 17:54:19 +00:00
|
|
|
}
|
2019-05-03 16:56:18 +00:00
|
|
|
|
|
|
|
Text::new("Show Inventory Test Button")
|
2019-05-06 18:49:25 +00:00
|
|
|
.right_from(state.ids.inventory_test_button, 10.0)
|
2019-05-04 17:29:19 +00:00
|
|
|
.font_size(14)
|
2019-05-03 16:56:18 +00:00
|
|
|
.font_id(self.fonts.opensans)
|
2019-05-06 18:49:25 +00:00
|
|
|
.graphics_for(state.ids.inventory_test_button)
|
2019-05-03 16:56:18 +00:00
|
|
|
.color(TEXT_COLOR)
|
2019-05-06 18:49:25 +00:00
|
|
|
.set(state.ids.inventory_test_button_label, ui);
|
2019-05-03 16:56:18 +00:00
|
|
|
|
2019-05-04 17:54:19 +00:00
|
|
|
// Debug
|
2019-05-07 05:40:03 +00:00
|
|
|
let show_debug =
|
|
|
|
ToggleButton::new(self.show.debug, self.imgs.check, self.imgs.check_checked)
|
|
|
|
.w_h(288.0 / 24.0, 288.0 / 24.0)
|
|
|
|
.down_from(state.ids.inventory_test_button, 7.0)
|
|
|
|
.hover_images(self.imgs.check_checked_mo, self.imgs.check_mo)
|
|
|
|
.press_images(self.imgs.check_press, self.imgs.check_press)
|
|
|
|
.set(state.ids.debug_button, ui);
|
2019-05-03 16:56:18 +00:00
|
|
|
|
2019-05-06 18:49:25 +00:00
|
|
|
if self.show.debug != show_debug {
|
2019-05-18 23:55:06 +00:00
|
|
|
events.push(Event::ToggleDebug);
|
2019-05-04 17:54:19 +00:00
|
|
|
}
|
2019-05-03 16:56:18 +00:00
|
|
|
|
|
|
|
Text::new("Show Debug Window")
|
|
|
|
.right_from(state.ids.debug_button, 10.0)
|
2019-05-04 17:29:19 +00:00
|
|
|
.font_size(14)
|
2019-05-03 16:56:18 +00:00
|
|
|
.font_id(self.fonts.opensans)
|
|
|
|
.graphics_for(state.ids.debug_button)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.ids.debug_button_label, ui);
|
|
|
|
}
|
|
|
|
|
2019-05-17 09:22:32 +00:00
|
|
|
// 2 Gameplay
|
2019-05-07 05:40:03 +00:00
|
|
|
if Button::image(if let SettingsTab::Gameplay = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button
|
|
|
|
})
|
|
|
|
.w_h(31.0 * 4.0, 12.0 * 4.0)
|
|
|
|
.hover_image(if let SettingsTab::Gameplay = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_hover
|
|
|
|
})
|
|
|
|
.press_image(if let SettingsTab::Gameplay = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_press
|
|
|
|
})
|
|
|
|
.right_from(state.ids.interface, 0.0)
|
|
|
|
.label("Gameplay")
|
|
|
|
.label_font_size(14)
|
|
|
|
.label_color(TEXT_COLOR)
|
|
|
|
.set(state.ids.gameplay, ui)
|
|
|
|
.was_clicked()
|
2019-05-03 16:56:18 +00:00
|
|
|
{
|
|
|
|
state.update(|s| s.settings_tab = SettingsTab::Gameplay);
|
|
|
|
}
|
|
|
|
|
2019-05-17 09:22:32 +00:00
|
|
|
// 3 Controls
|
2019-05-03 16:56:18 +00:00
|
|
|
if Button::image(if let SettingsTab::Controls = state.settings_tab {
|
2019-05-07 05:40:03 +00:00
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button
|
|
|
|
})
|
|
|
|
.w_h(31.0 * 4.0, 12.0 * 4.0)
|
|
|
|
.hover_image(if let SettingsTab::Controls = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_hover
|
|
|
|
})
|
|
|
|
.press_image(if let SettingsTab::Controls = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_press
|
|
|
|
})
|
|
|
|
.right_from(state.ids.gameplay, 0.0)
|
|
|
|
.label("Controls")
|
|
|
|
.label_font_size(14)
|
|
|
|
.label_color(TEXT_COLOR)
|
|
|
|
.set(state.ids.controls, ui)
|
|
|
|
.was_clicked()
|
2019-05-03 16:56:18 +00:00
|
|
|
{
|
|
|
|
state.update(|s| s.settings_tab = SettingsTab::Controls);
|
|
|
|
}
|
2019-05-04 17:29:19 +00:00
|
|
|
if let SettingsTab::Controls = state.settings_tab {
|
2019-05-07 05:40:03 +00:00
|
|
|
Text::new(
|
|
|
|
"Free Cursor\n\
|
2019-05-04 17:29:19 +00:00
|
|
|
Toggle Help Window\n\
|
|
|
|
Toggle Interface\n\
|
|
|
|
Toggle FPS and Debug Info\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
Move Forward\n\
|
|
|
|
Move Left\n\
|
|
|
|
Move Right\n\
|
|
|
|
Move Backwards\n\
|
|
|
|
\n\
|
|
|
|
Jump\n\
|
|
|
|
\n\
|
|
|
|
Dodge\n\
|
|
|
|
\n\
|
|
|
|
Auto Walk\n\
|
|
|
|
\n\
|
|
|
|
Sheathe/Draw Weapons\n\
|
|
|
|
\n\
|
|
|
|
Put on/Remove Helmet\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
Basic Attack\n\
|
|
|
|
Secondary Attack/Block/Aim\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
Skillbar Slot 1\n\
|
|
|
|
Skillbar Slot 2\n\
|
|
|
|
Skillbar Slot 3\n\
|
|
|
|
Skillbar Slot 4\n\
|
|
|
|
Skillbar Slot 5\n\
|
|
|
|
Skillbar Slot 6\n\
|
|
|
|
Skillbar Slot 7\n\
|
|
|
|
Skillbar Slot 8\n\
|
|
|
|
Skillbar Slot 9\n\
|
|
|
|
Skillbar Slot 10\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
Pause Menu\n\
|
|
|
|
Settings\n\
|
|
|
|
Social\n\
|
|
|
|
Map\n\
|
|
|
|
Spellbook\n\
|
|
|
|
Character\n\
|
|
|
|
Questlog\n\
|
|
|
|
Bag\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
Send Chat Message\n\
|
|
|
|
Scroll Chat\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
Chat commands: \n\
|
|
|
|
\n\
|
|
|
|
/alias [Name] - Change your Chat Name \n\
|
|
|
|
/tp [Name] - Teleports you to another player
|
|
|
|
",
|
2019-05-07 05:40:03 +00:00
|
|
|
)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.top_left_with_margins_on(state.ids.settings_content, 5.0, 5.0)
|
|
|
|
.font_id(self.fonts.opensans)
|
|
|
|
.font_size(18)
|
|
|
|
.set(state.ids.controls_text, ui);
|
2019-05-17 09:22:32 +00:00
|
|
|
// TODO: Replace with buttons that show actual keybinds and allow the user to change them.
|
2019-05-07 05:40:03 +00:00
|
|
|
Text::new(
|
|
|
|
"TAB\n\
|
|
|
|
F1\n\
|
|
|
|
F2\n\
|
|
|
|
F3\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
W\n\
|
|
|
|
A\n\
|
|
|
|
S\n\
|
|
|
|
D\n\
|
|
|
|
\n\
|
|
|
|
SPACE\n\
|
|
|
|
\n\
|
|
|
|
??\n\
|
|
|
|
\n\
|
|
|
|
??\n\
|
|
|
|
\n\
|
|
|
|
??\n\
|
|
|
|
\n\
|
|
|
|
??\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
L-Click\n\
|
|
|
|
R-Click\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
1\n\
|
|
|
|
2\n\
|
|
|
|
3\n\
|
|
|
|
4\n\
|
|
|
|
5\n\
|
|
|
|
6\n\
|
|
|
|
7\n\
|
|
|
|
8\n\
|
|
|
|
9\n\
|
|
|
|
0\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
ESC\n\
|
|
|
|
N\n\
|
|
|
|
O\n\
|
|
|
|
M\n\
|
|
|
|
P\n\
|
|
|
|
C\n\
|
|
|
|
L\n\
|
|
|
|
B\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
ENTER\n\
|
|
|
|
Mousewheel\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
\n\
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.right_from(state.ids.controls_text, 0.0)
|
|
|
|
.font_id(self.fonts.opensans)
|
|
|
|
.font_size(18)
|
|
|
|
.set(state.ids.controls_controls, ui);
|
|
|
|
}
|
2019-05-17 09:22:32 +00:00
|
|
|
// 4 Video
|
2019-05-07 05:40:03 +00:00
|
|
|
if Button::image(if let SettingsTab::Video = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button
|
|
|
|
})
|
|
|
|
.w_h(31.0 * 4.0, 12.0 * 4.0)
|
|
|
|
.hover_image(if let SettingsTab::Video = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_hover
|
|
|
|
})
|
|
|
|
.press_image(if let SettingsTab::Video = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_press
|
|
|
|
})
|
|
|
|
.right_from(state.ids.controls, 0.0)
|
|
|
|
.label("Video")
|
|
|
|
.parent(state.ids.settings_r)
|
|
|
|
.label_font_size(14)
|
|
|
|
.label_color(TEXT_COLOR)
|
|
|
|
.set(state.ids.video, ui)
|
|
|
|
.was_clicked()
|
2019-05-03 16:56:18 +00:00
|
|
|
{
|
|
|
|
state.update(|s| s.settings_tab = SettingsTab::Video);
|
|
|
|
}
|
2019-05-18 23:22:30 +00:00
|
|
|
// Contents
|
2019-05-18 23:55:06 +00:00
|
|
|
if let SettingsTab::Video = state.settings_tab {
|
|
|
|
Text::new("Viewdistance")
|
|
|
|
.top_left_with_margins_on(state.ids.settings_content, 10.0, 10.0)
|
|
|
|
.font_size(14)
|
|
|
|
.font_id(self.fonts.opensans)
|
|
|
|
.color(TEXT_COLOR)
|
|
|
|
.set(state.ids.vd_slider_text, ui);
|
2019-05-03 16:56:18 +00:00
|
|
|
|
2019-05-18 23:55:06 +00:00
|
|
|
if let Some(new_val) = ImageSlider::discrete(
|
|
|
|
self.current_vd,
|
|
|
|
1,
|
|
|
|
25,
|
|
|
|
self.imgs.slider_indicator,
|
|
|
|
self.imgs.slider,
|
|
|
|
)
|
|
|
|
.w_h(104.0, 22.0)
|
2019-05-18 23:22:30 +00:00
|
|
|
.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)
|
2019-05-18 23:55:06 +00:00
|
|
|
{
|
2019-05-19 00:45:02 +00:00
|
|
|
events.push(Event::AdjustViewDistance(new_val as u32));
|
2019-05-18 23:55:06 +00:00
|
|
|
}
|
2019-05-18 23:22:30 +00:00
|
|
|
}
|
2019-05-17 09:22:32 +00:00
|
|
|
// 5 Sound
|
2019-05-03 16:56:18 +00:00
|
|
|
if Button::image(if let SettingsTab::Sound = state.settings_tab {
|
2019-05-07 05:40:03 +00:00
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button
|
|
|
|
})
|
|
|
|
.w_h(31.0 * 4.0, 12.0 * 4.0)
|
|
|
|
.hover_image(if let SettingsTab::Sound = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_hover
|
|
|
|
})
|
|
|
|
.press_image(if let SettingsTab::Sound = state.settings_tab {
|
|
|
|
self.imgs.settings_button_pressed
|
|
|
|
} else {
|
|
|
|
self.imgs.settings_button_press
|
|
|
|
})
|
|
|
|
.right_from(state.ids.video, 0.0)
|
|
|
|
.parent(state.ids.settings_r)
|
|
|
|
.label("Sound")
|
|
|
|
.label_font_size(14)
|
|
|
|
.label_color(TEXT_COLOR)
|
|
|
|
.set(state.ids.sound, ui)
|
|
|
|
.was_clicked()
|
2019-05-03 16:56:18 +00:00
|
|
|
{
|
|
|
|
state.update(|s| s.settings_tab = SettingsTab::Sound);
|
|
|
|
}
|
|
|
|
|
2019-05-18 23:55:06 +00:00
|
|
|
events
|
2019-05-03 16:56:18 +00:00
|
|
|
}
|
|
|
|
}
|