Fix sound volume change and inventory overflow on Android (#207)

* Android changing volume fix. Added arrows to indicate volume buttons

* Fix inventory overflowing on Android
This commit is contained in:
biroder 2023-04-01 20:27:30 +03:00 committed by GitHub
parent 51834be404
commit f99b452073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -133,7 +133,11 @@ fn get_insets() -> GameResult<(f32, f32, f32, f32)> {
vm_env.get_int_array_region(field, 0, &mut elements)?;
vm_env.delete_local_ref(JObject::from_raw(field));
//Game always runs with horizontal orientation so top and bottom cutouts not needed and only wastes piece of the screen
elements[1] = 0;
elements[3] = 0;
Ok((elements[0] as f32, elements[1] as f32, elements[2] as f32, elements[3] as f32))
}
}

View File

@ -594,6 +594,24 @@ impl<T: std::cmp::PartialEq + std::default::Default + Clone> Menu<T> {
graphics::draw_rect(ctx, bar_rect, Color::new(1.0, 1.0, 1.0, 1.0))?;
}
#[cfg(target_os = "android")]
{
state
.font
.builder()
.x(self.x as f32 - 25.0)
.y(y)
.shadow(true)
.draw("<", ctx, &state.constants, &mut state.texture_set)?;
state
.font
.builder()
.x((self.x + self.width as isize) as f32 + 15.0)
.y(y)
.shadow(true)
.draw(">", ctx, &state.constants, &mut state.texture_set)?;
}
}
MenuEntry::NewSave => {
state.font.builder().position(self.x as f32 + 20.0, y).draw(
@ -829,6 +847,7 @@ impl<T: std::cmp::PartialEq + std::default::Default + Clone> Menu<T> {
|| state.touch_controls.consume_click_in(left_entry_bounds) =>
{
state.sound_manager.play_sfx(1);
self.selected = idx.clone();
return MenuSelectionResult::Left(self.selected.clone(), entry, -1);
}
MenuEntry::Options(_, _, _) | MenuEntry::OptionsBar(_, _)
@ -836,6 +855,7 @@ impl<T: std::cmp::PartialEq + std::default::Default + Clone> Menu<T> {
|| state.touch_controls.consume_click_in(right_entry_bounds) =>
{
state.sound_manager.play_sfx(1);
self.selected = idx.clone();
return MenuSelectionResult::Right(self.selected.clone(), entry, 1);
}
MenuEntry::DescriptiveOptions(_, _, _, _)