mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-11-29 15:56:53 +00:00
applying suggested changes
This commit is contained in:
parent
3d1ebf76a3
commit
df297819fe
|
|
@ -9,13 +9,15 @@ use crate::shared_game_state::SharedGameState;
|
||||||
pub mod settings_menu;
|
pub mod settings_menu;
|
||||||
|
|
||||||
pub struct MenuSaveInfo {}
|
pub struct MenuSaveInfo {}
|
||||||
|
|
||||||
pub enum MenuEntry {
|
pub enum MenuEntry {
|
||||||
Hidden,
|
Hidden,
|
||||||
Active(String),
|
Active(String),
|
||||||
DisabledWhite(String),
|
DisabledWhite(String),
|
||||||
Disabled(String),
|
Disabled(String),
|
||||||
Toggle(String, bool),
|
Toggle(String, bool),
|
||||||
Options(String, usize, Vec<String>, Vec<String>),
|
Options(String, usize, Vec<String>),
|
||||||
|
DescriptiveOptions(String, usize, Vec<String>, Vec<String>),
|
||||||
SaveData(MenuSaveInfo),
|
SaveData(MenuSaveInfo),
|
||||||
NewSave,
|
NewSave,
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +30,8 @@ impl MenuEntry {
|
||||||
MenuEntry::DisabledWhite(_) => 14.0,
|
MenuEntry::DisabledWhite(_) => 14.0,
|
||||||
MenuEntry::Disabled(_) => 14.0,
|
MenuEntry::Disabled(_) => 14.0,
|
||||||
MenuEntry::Toggle(_, _) => 14.0,
|
MenuEntry::Toggle(_, _) => 14.0,
|
||||||
MenuEntry::Options(_, _, _, _) => 14.0,
|
MenuEntry::Options(_, _, _) => 14.0,
|
||||||
|
MenuEntry::DescriptiveOptions(_, _, _, _) => 14.0,
|
||||||
MenuEntry::SaveData(_) => 30.0,
|
MenuEntry::SaveData(_) => 30.0,
|
||||||
MenuEntry::NewSave => 30.0,
|
MenuEntry::NewSave => 30.0,
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +44,8 @@ impl MenuEntry {
|
||||||
MenuEntry::DisabledWhite(_) => false,
|
MenuEntry::DisabledWhite(_) => false,
|
||||||
MenuEntry::Disabled(_) => false,
|
MenuEntry::Disabled(_) => false,
|
||||||
MenuEntry::Toggle(_, _) => true,
|
MenuEntry::Toggle(_, _) => true,
|
||||||
MenuEntry::Options(_, _, _, _) => true,
|
MenuEntry::Options(_, _, _) => true,
|
||||||
|
MenuEntry::DescriptiveOptions(_, _, _, _) => true,
|
||||||
MenuEntry::SaveData(_) => true,
|
MenuEntry::SaveData(_) => true,
|
||||||
MenuEntry::NewSave => true,
|
MenuEntry::NewSave => true,
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +273,29 @@ impl Menu {
|
||||||
ctx,
|
ctx,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
MenuEntry::Options(name, index, value, description) => {
|
MenuEntry::Options(name, index, value) => {
|
||||||
|
let value_text = if let Some(text) = value.get(*index) { text.as_str() } else { "???" };
|
||||||
|
let name_text_len = state.font.text_width(name.chars(), &state.constants);
|
||||||
|
|
||||||
|
state.font.draw_text(
|
||||||
|
name.chars(),
|
||||||
|
self.x as f32 + 20.0,
|
||||||
|
y,
|
||||||
|
&state.constants,
|
||||||
|
&mut state.texture_set,
|
||||||
|
ctx,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
state.font.draw_text(
|
||||||
|
value_text.chars(),
|
||||||
|
self.x as f32 + 25.0 + name_text_len,
|
||||||
|
y,
|
||||||
|
&state.constants,
|
||||||
|
&mut state.texture_set,
|
||||||
|
ctx,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
MenuEntry::DescriptiveOptions(name, index, value, description) => {
|
||||||
let value_text = if let Some(text) = value.get(*index) { text.as_str() } else { "???" };
|
let value_text = if let Some(text) = value.get(*index) { text.as_str() } else { "???" };
|
||||||
let description_text = if let Some(text) = description.get(*index) { text.as_str() } else { "???" };
|
let description_text = if let Some(text) = description.get(*index) { text.as_str() } else { "???" };
|
||||||
let name_text_len = state.font.text_width(name.chars(), &state.constants);
|
let name_text_len = state.font.text_width(name.chars(), &state.constants);
|
||||||
|
|
@ -294,7 +320,7 @@ impl Menu {
|
||||||
|
|
||||||
state.font.draw_colored_text(
|
state.font.draw_colored_text(
|
||||||
description_text.chars(),
|
description_text.chars(),
|
||||||
self.x as f32 + 40.0,
|
self.x as f32 + 20.0,
|
||||||
y + 14.0,
|
y + 14.0,
|
||||||
(0xa0, 0xa0, 0xff, 0xff),
|
(0xa0, 0xa0, 0xff, 0xff),
|
||||||
&state.constants,
|
&state.constants,
|
||||||
|
|
@ -356,18 +382,26 @@ impl Menu {
|
||||||
y += entry.height() as f32;
|
y += entry.height() as f32;
|
||||||
|
|
||||||
match entry {
|
match entry {
|
||||||
MenuEntry::Active(_) | MenuEntry::Toggle(_, _) | MenuEntry::Options(_, _, _, _)
|
MenuEntry::Active(_) | MenuEntry::Toggle(_, _) | MenuEntry::Options(_, _, _) | MenuEntry::DescriptiveOptions(_, _, _, _)
|
||||||
if (self.selected == idx && controller.trigger_ok())
|
if (self.selected == idx && controller.trigger_ok())
|
||||||
|| state.touch_controls.consume_click_in(entry_bounds) =>
|
|| state.touch_controls.consume_click_in(entry_bounds) =>
|
||||||
{
|
{
|
||||||
state.sound_manager.play_sfx(18);
|
state.sound_manager.play_sfx(18);
|
||||||
return MenuSelectionResult::Selected(idx, entry);
|
return MenuSelectionResult::Selected(idx, entry);
|
||||||
}
|
}
|
||||||
MenuEntry::Options(_, _, _, _) if controller.trigger_left() => {
|
MenuEntry::Options(_, _, _) if controller.trigger_left() => {
|
||||||
state.sound_manager.play_sfx(1);
|
state.sound_manager.play_sfx(1);
|
||||||
return MenuSelectionResult::Left(self.selected, entry);
|
return MenuSelectionResult::Left(self.selected, entry);
|
||||||
}
|
}
|
||||||
MenuEntry::Options(_, _, _, _) if controller.trigger_right() => {
|
MenuEntry::Options(_, _, _) if controller.trigger_right() => {
|
||||||
|
state.sound_manager.play_sfx(1);
|
||||||
|
return MenuSelectionResult::Right(self.selected, entry);
|
||||||
|
}
|
||||||
|
MenuEntry::DescriptiveOptions(_, _, _, _) if controller.trigger_left() => {
|
||||||
|
state.sound_manager.play_sfx(1);
|
||||||
|
return MenuSelectionResult::Left(self.selected, entry);
|
||||||
|
}
|
||||||
|
MenuEntry::DescriptiveOptions(_, _, _, _) if controller.trigger_right() => {
|
||||||
state.sound_manager.play_sfx(1);
|
state.sound_manager.play_sfx(1);
|
||||||
return MenuSelectionResult::Right(self.selected, entry);
|
return MenuSelectionResult::Right(self.selected, entry);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,13 @@ impl SettingsMenu {
|
||||||
"Game timing:".to_owned(),
|
"Game timing:".to_owned(),
|
||||||
if state.settings.timing_mode == TimingMode::_50Hz { 0 } else { 1 },
|
if state.settings.timing_mode == TimingMode::_50Hz { 0 } else { 1 },
|
||||||
vec!["50tps (freeware)".to_owned(), "60tps (CS+)".to_owned()],
|
vec!["50tps (freeware)".to_owned(), "60tps (CS+)".to_owned()],
|
||||||
vec!["".to_owned(),"".to_owned()],
|
|
||||||
));
|
));
|
||||||
|
|
||||||
self.main.push_entry(MenuEntry::Active(DISCORD_LINK.to_owned()));
|
self.main.push_entry(MenuEntry::Active(DISCORD_LINK.to_owned()));
|
||||||
|
|
||||||
self.main.push_entry(MenuEntry::Active("< Back".to_owned()));
|
self.main.push_entry(MenuEntry::Active("< Back".to_owned()));
|
||||||
|
|
||||||
self.sound.push_entry(MenuEntry::Options(
|
self.sound.push_entry(MenuEntry::DescriptiveOptions(
|
||||||
"BGM Interpolation:".to_owned(),
|
"BGM Interpolation:".to_owned(),
|
||||||
state.settings.organya_interpolation as usize,
|
state.settings.organya_interpolation as usize,
|
||||||
vec![
|
vec![
|
||||||
|
|
@ -86,8 +85,8 @@ impl SettingsMenu {
|
||||||
vec![
|
vec![
|
||||||
"(Fastest, lowest quality)".to_owned(),
|
"(Fastest, lowest quality)".to_owned(),
|
||||||
"(Fast, similar to freeware on Vista+)".to_owned(),
|
"(Fast, similar to freeware on Vista+)".to_owned(),
|
||||||
"(Cosine interp)".to_owned(),
|
"(Cosine interpolation)".to_owned(),
|
||||||
"(Cubic interp)".to_owned(),
|
"(Cubic interpolation)".to_owned(),
|
||||||
"(Slowest, similar to freeware on XP)".to_owned()
|
"(Slowest, similar to freeware on XP)".to_owned()
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
|
|
@ -132,7 +131,7 @@ impl SettingsMenu {
|
||||||
self.current = CurrentMenu::SoundMenu;
|
self.current = CurrentMenu::SoundMenu;
|
||||||
}
|
}
|
||||||
MenuSelectionResult::Selected(2, toggle) => {
|
MenuSelectionResult::Selected(2, toggle) => {
|
||||||
if let MenuEntry::Options(_, value, _, _) = toggle {
|
if let MenuEntry::Options(_, value, _) = toggle {
|
||||||
match state.settings.timing_mode {
|
match state.settings.timing_mode {
|
||||||
TimingMode::_50Hz => {
|
TimingMode::_50Hz => {
|
||||||
state.settings.timing_mode = TimingMode::_60Hz;
|
state.settings.timing_mode = TimingMode::_60Hz;
|
||||||
|
|
@ -213,7 +212,7 @@ impl SettingsMenu {
|
||||||
},
|
},
|
||||||
CurrentMenu::SoundMenu => match self.sound.tick(controller, state) {
|
CurrentMenu::SoundMenu => match self.sound.tick(controller, state) {
|
||||||
MenuSelectionResult::Selected(0, toggle) => {
|
MenuSelectionResult::Selected(0, toggle) => {
|
||||||
if let MenuEntry::Options(_, value, _, _) = toggle {
|
if let MenuEntry::DescriptiveOptions(_, value, _, _) = toggle {
|
||||||
let (new_mode, new_value) = match *value {
|
let (new_mode, new_value) = match *value {
|
||||||
0 => (InterpolationMode::Linear, 1),
|
0 => (InterpolationMode::Linear, 1),
|
||||||
1 => (InterpolationMode::Cosine, 2),
|
1 => (InterpolationMode::Cosine, 2),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue