Use static string literals instead of String for scene IDs
This commit is contained in:
parent
3692736a61
commit
b3b69756e6
2 changed files with 8 additions and 6 deletions
|
|
@ -29,7 +29,7 @@ impl AsMut<Scene> for Scene {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type SceneID = String;
|
type SceneID = &'static str;
|
||||||
|
|
||||||
pub struct SceneManager {
|
pub struct SceneManager {
|
||||||
scenes: HashMap<SceneID, Scene>,
|
scenes: HashMap<SceneID, Scene>,
|
||||||
|
|
@ -55,7 +55,7 @@ impl SceneManager {
|
||||||
|
|
||||||
pub fn current_mut(&mut self) -> &mut Scene {
|
pub fn current_mut(&mut self) -> &mut Scene {
|
||||||
match &mut self.active_scene {
|
match &mut self.active_scene {
|
||||||
Some(id) => self.scenes.get_mut(id.as_mut()).unwrap().as_mut(),
|
Some(id) => self.scenes.get_mut(id).unwrap().as_mut(),
|
||||||
None => panic!("No active scene"),
|
None => panic!("No active scene"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ use raidillon_glium::GliumPlatform;
|
||||||
const TEST_GLTF: &str = "pink-monkey.gltf";
|
const TEST_GLTF: &str = "pink-monkey.gltf";
|
||||||
|
|
||||||
const RENDERING_TEST_SYSTEM: &str = "rendering_test_system";
|
const RENDERING_TEST_SYSTEM: &str = "rendering_test_system";
|
||||||
|
|
||||||
|
const MAIN_SCENE_ID: &str = "main_scene";
|
||||||
|
|
||||||
struct RenderingTestSystem;
|
struct RenderingTestSystem;
|
||||||
|
|
||||||
impl System for RenderingTestSystem {
|
impl System for RenderingTestSystem {
|
||||||
|
|
@ -52,13 +55,12 @@ fn main() {
|
||||||
engine.system_manager.add_system(RENDERING_TEST_SYSTEM, Box::new(RenderingTestSystem));
|
engine.system_manager.add_system(RENDERING_TEST_SYSTEM, Box::new(RenderingTestSystem));
|
||||||
|
|
||||||
// Set up the scene
|
// Set up the scene
|
||||||
let main_scene_id = "Main".to_owned();
|
|
||||||
let main_scene = Scene::new(
|
let main_scene = Scene::new(
|
||||||
main_scene_id.clone(),
|
MAIN_SCENE_ID.to_owned(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
engine.scene_manager.add_scene(main_scene_id.clone(), main_scene);
|
engine.scene_manager.add_scene(MAIN_SCENE_ID, main_scene);
|
||||||
engine.scene_manager.set_active_scene(main_scene_id.clone());
|
engine.scene_manager.set_active_scene(MAIN_SCENE_ID);
|
||||||
|
|
||||||
#[cfg(feature = "glium")]
|
#[cfg(feature = "glium")]
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue