mirror of
https://github.com/lisk77/comet.git
synced 2025-12-12 09:08:49 +00:00
refactor(renderer): texture look up does not need a String as key anymore
This commit is contained in:
parent
4ed42b3de0
commit
8aec280447
2 changed files with 8 additions and 8 deletions
|
|
@ -131,7 +131,7 @@ pub trait Collider {
|
||||||
pub trait Render {
|
pub trait Render {
|
||||||
fn is_visible(&self) -> bool;
|
fn is_visible(&self) -> bool;
|
||||||
fn set_visibility(&mut self, is_visible: bool);
|
fn set_visibility(&mut self, is_visible: bool);
|
||||||
fn get_texture(&self) -> String;
|
fn get_texture(&self) -> &str;
|
||||||
fn set_texture(&mut self, texture: &'static str);
|
fn set_texture(&mut self, texture: &'static str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,8 +320,8 @@ impl Render for Render2D {
|
||||||
self.is_visible = is_visible;
|
self.is_visible = is_visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_texture(&self) -> String {
|
fn get_texture(&self) -> &str {
|
||||||
self.texture_name.parse().unwrap()
|
self.texture_name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use the actual file name of the texture instead of the path
|
/// Use the actual file name of the texture instead of the path
|
||||||
|
|
|
||||||
|
|
@ -555,19 +555,19 @@ impl<'a> Renderer2D<'a> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_texture_region(&self, texture_path: String) -> Option<&TextureRegion> {
|
fn get_texture_region(&self, texture_path: &str) -> Option<&TextureRegion> {
|
||||||
if !self
|
if !self
|
||||||
.resource_manager
|
.resource_manager
|
||||||
.texture_atlas()
|
.texture_atlas()
|
||||||
.textures()
|
.textures()
|
||||||
.contains_key(&texture_path)
|
.contains_key(texture_path)
|
||||||
{
|
{
|
||||||
error!("Texture {} not found in atlas", &texture_path);
|
error!("Texture {} not found in atlas", texture_path);
|
||||||
}
|
}
|
||||||
self.resource_manager
|
self.resource_manager
|
||||||
.texture_atlas()
|
.texture_atlas()
|
||||||
.textures()
|
.textures()
|
||||||
.get(&texture_path)
|
.get(texture_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_glyph_region(&self, glyph: char, font: String) -> &TextureRegion {
|
fn get_glyph_region(&self, glyph: char, font: String) -> &TextureRegion {
|
||||||
|
|
@ -772,7 +772,7 @@ impl<'a> Renderer2D<'a> {
|
||||||
let rotation_angle = transform_component.rotation().to_radians();
|
let rotation_angle = transform_component.rotation().to_radians();
|
||||||
|
|
||||||
let region =
|
let region =
|
||||||
match self.get_texture_region(renderer_component.get_texture().to_string()) {
|
match self.get_texture_region(renderer_component.get_texture()) {
|
||||||
Some(r) => r,
|
Some(r) => r,
|
||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue