From 74451f819cca11a29516ecb014069cfe82f38840 Mon Sep 17 00:00:00 2001 From: Gwilym Inzani Date: Wed, 21 Feb 2024 12:59:02 +0000 Subject: [PATCH] More impl Into> and fix compile errors --- CHANGELOG.md | 3 +++ agb/src/display/font.rs | 2 +- agb/src/display/tiled/infinite_scrolled_map.rs | 5 ++--- agb/src/display/tiled/map.rs | 4 ++-- examples/hyperspace-roll/src/background.rs | 10 +++++----- examples/hyperspace-roll/src/battle.rs | 2 +- examples/hyperspace-roll/src/customise.rs | 4 ++-- .../the-dungeon-puzzlers-lament/src/backgrounds.rs | 4 ++-- .../the-hat-chooses-the-wizard/src/level_display.rs | 4 ++-- examples/the-hat-chooses-the-wizard/src/lib.rs | 2 +- .../the-hat-chooses-the-wizard/src/splash_screen.rs | 2 +- 11 files changed, 22 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d73cb095..3dd7934c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - An abstraction over hblank DMA to allow for cool effects like gradients and circular windows. See the dma_effect* examples. - Expermental and incomplete support for MIDI files with agb-tracker. +### Change +- Bcakground `set_scroll_pos` and `set_tile` now accepts an `impl Into>` rather than a `Vector`. + ## [0.18.1] - 2024/02/06 ### Added diff --git a/agb/src/display/font.rs b/agb/src/display/font.rs index fbc5cf17..aef42ce2 100644 --- a/agb/src/display/font.rs +++ b/agb/src/display/font.rs @@ -228,7 +228,7 @@ impl<'a, 'b> TextRenderer<'b> { for ((x, y), tile) in self.tiles.iter() { bg.set_tile( vram_manager, - (self.tile_pos.x + *x as u16, self.tile_pos.y + *y as u16).into(), + (self.tile_pos.x + *x as u16, self.tile_pos.y + *y as u16), &tile.tile_set(), tile.tile_setting(), ); diff --git a/agb/src/display/tiled/infinite_scrolled_map.rs b/agb/src/display/tiled/infinite_scrolled_map.rs index cd510810..e936808e 100644 --- a/agb/src/display/tiled/infinite_scrolled_map.rs +++ b/agb/src/display/tiled/infinite_scrolled_map.rs @@ -273,7 +273,7 @@ impl<'a> InfiniteScrolledMap<'a> { self.map.set_tile( vram, - (x_idx as u16, (y_idx + copy_from as usize) as u16).into(), + (x_idx as u16, (y_idx + copy_from as usize) as u16), tileset, tile_setting, ); @@ -373,8 +373,7 @@ impl<'a> InfiniteScrolledMap<'a> { ( size.tile_pos_x(tile_x - self.offset.x), size.tile_pos_y(tile_y - self.offset.y), - ) - .into(), + ), tileset, tile_setting, ); diff --git a/agb/src/display/tiled/map.rs b/agb/src/display/tiled/map.rs index c7185c3c..66b7f560 100644 --- a/agb/src/display/tiled/map.rs +++ b/agb/src/display/tiled/map.rs @@ -225,7 +225,7 @@ impl RegularMap { pub fn set_tile( &mut self, vram: &mut VRamManager, - pos: Vector2D, + pos: impl Into>, tileset: &TileSet<'_>, tile_setting: TileSetting, ) { @@ -237,7 +237,7 @@ impl RegularMap { self.colours() ); - let pos = self.map_size().gba_offset(pos); + let pos = self.map_size().gba_offset(pos.into()); self.set_tile_at_pos(vram, pos, tileset, tile_setting); } diff --git a/examples/hyperspace-roll/src/background.rs b/examples/hyperspace-roll/src/background.rs index c7fb6229..cfcdc053 100644 --- a/examples/hyperspace-roll/src/background.rs +++ b/examples/hyperspace-roll/src/background.rs @@ -30,7 +30,7 @@ pub(crate) fn load_help_text( background.set_tile( vram, - (x + at_tile.0, at_tile.1).into(), + (x + at_tile.0, at_tile.1), &help_tiledata.tiles, help_tiledata.tile_settings[tile_id as usize], ) @@ -53,7 +53,7 @@ pub(crate) fn load_description( let tile_id = y * 8 + x + 8 * 11 * (face_id as u16 % 10); descriptions_map.set_tile( vram, - (x, y).into(), + (x, y), &description_data.tiles, description_data.tile_settings[tile_id as usize], ) @@ -74,15 +74,15 @@ fn create_background_map(map: &mut RegularMap, vram: &mut VRamManager, stars_til backgrounds::stars.tile_settings[tile_id as usize] }; - map.set_tile(vram, (x, y).into(), stars_tileset, tile_setting); + map.set_tile(vram, (x, y), stars_tileset, tile_setting); } } - map.set_scroll_pos((0i16, rng::gen().rem_euclid(8) as i16).into()); + map.set_scroll_pos((0i16, rng::gen().rem_euclid(8) as i16)); } pub fn show_title_screen(background: &mut RegularMap, vram: &mut VRamManager, sfx: &mut Sfx) { - background.set_scroll_pos((0i16, 0).into()); + background.set_scroll_pos((0i16, 0)); vram.set_background_palettes(backgrounds::PALETTES); background.set_visible(false); diff --git a/examples/hyperspace-roll/src/battle.rs b/examples/hyperspace-roll/src/battle.rs index d1233eaa..7820242a 100644 --- a/examples/hyperspace-roll/src/battle.rs +++ b/examples/hyperspace-roll/src/battle.rs @@ -489,7 +489,7 @@ pub(crate) fn battle_screen( agb.sfx.battle(); agb.sfx.frame(); - help_background.set_scroll_pos((-16i16, -97i16).into()); + help_background.set_scroll_pos((-16i16, -97i16)); crate::background::load_help_text(&mut agb.vram, help_background, 1, (0, 0)); crate::background::load_help_text(&mut agb.vram, help_background, 2, (0, 1)); diff --git a/examples/hyperspace-roll/src/customise.rs b/examples/hyperspace-roll/src/customise.rs index be04e699..513e4df7 100644 --- a/examples/hyperspace-roll/src/customise.rs +++ b/examples/hyperspace-roll/src/customise.rs @@ -163,9 +163,9 @@ pub(crate) fn customise_screen( ) -> PlayerDice { agb.sfx.customise(); agb.sfx.frame(); - descriptions_map.set_scroll_pos((-174i16, -52).into()); + descriptions_map.set_scroll_pos((-174i16, -52)); - help_background.set_scroll_pos((-148i16, -34).into()); + help_background.set_scroll_pos((-148i16, -34)); crate::background::load_help_text(&mut agb.vram, help_background, 0, (0, 0)); // create the dice diff --git a/examples/the-dungeon-puzzlers-lament/src/backgrounds.rs b/examples/the-dungeon-puzzlers-lament/src/backgrounds.rs index a965c653..0b935d67 100644 --- a/examples/the-dungeon-puzzlers-lament/src/backgrounds.rs +++ b/examples/the-dungeon-puzzlers-lament/src/backgrounds.rs @@ -26,7 +26,7 @@ pub fn load_ui(map: &mut RegularMap, vram_manager: &mut VRamManager) { let tile_pos = y * 30 + x; let tile_setting = tilemaps::UI_BACKGROUND_MAP[tile_pos as usize]; - map.set_tile(vram_manager, (x, y).into(), &ui_tileset, tile_setting); + map.set_tile(vram_manager, (x, y), &ui_tileset, tile_setting); } } } @@ -45,7 +45,7 @@ pub fn load_level_background( let tile_pos = y * 22 + x; let tile_setting = level_map[tile_pos as usize]; - map.set_tile(vram_manager, (x, y).into(), &level_tileset, tile_setting); + map.set_tile(vram_manager, (x, y), &level_tileset, tile_setting); } } } diff --git a/examples/the-hat-chooses-the-wizard/src/level_display.rs b/examples/the-hat-chooses-the-wizard/src/level_display.rs index 006a8941..2c577581 100644 --- a/examples/the-hat-chooses-the-wizard/src/level_display.rs +++ b/examples/the-hat-chooses-the-wizard/src/level_display.rs @@ -28,8 +28,8 @@ pub fn write_level( .iter() .enumerate() { - map.set_tile(vram, (i as u16, 0).into(), tileset, tile_settings[tile]); + map.set_tile(vram, (i as u16, 0), tileset, tile_settings[tile]); } - map.set_scroll_pos((-(WIDTH / 2 - 7 * 8 / 2) as i16, -(HEIGHT / 2 - 4) as i16).into()); + map.set_scroll_pos((-(WIDTH / 2 - 7 * 8 / 2) as i16, -(HEIGHT / 2 - 4) as i16)); } diff --git a/examples/the-hat-chooses-the-wizard/src/lib.rs b/examples/the-hat-chooses-the-wizard/src/lib.rs index 75665950..2bac6a4f 100644 --- a/examples/the-hat-chooses-the-wizard/src/lib.rs +++ b/examples/the-hat-chooses-the-wizard/src/lib.rs @@ -794,7 +794,7 @@ pub fn main(mut agb: agb::Gba) -> ! { for x in 0..32u16 { world_display.set_tile( &mut vram, - (x, y).into(), + (x, y), &tileset, tile_sheet::background.tile_settings[level_display::BLANK], ); diff --git a/examples/the-hat-chooses-the-wizard/src/splash_screen.rs b/examples/the-hat-chooses-the-wizard/src/splash_screen.rs index b88d8d78..82680847 100644 --- a/examples/the-hat-chooses-the-wizard/src/splash_screen.rs +++ b/examples/the-hat-chooses-the-wizard/src/splash_screen.rs @@ -17,7 +17,7 @@ pub fn show_splash_screen( map: &mut RegularMap, vram: &mut VRamManager, ) { - map.set_scroll_pos((0i16, 0i16).into()); + map.set_scroll_pos((0i16, 0i16)); let tile_data = match which { SplashScreen::Start => splash_screens::splash, SplashScreen::End => splash_screens::thanks_for_playing,