public void addScreen(ScreenId id, Screen s, bool update = true, bool draw = true) { s.setUpdate(update); s.setDraw(draw); s.LoadContent(); screens.Add(id, s); }
public static void Load() { Screen mainmenu = ScreenManager.getScreen(ScreenId.MainMenu); mainmenu.setUpdate(false); if (!Directory.Exists(@".\saves")) { Directory.CreateDirectory(@".\saves"); } try { Stream stream = File.Open(@".\saves\save1.save", FileMode.Open); if (stream != null) { GameScreen game = (GameScreen)ScreenManager.getScreen(ScreenId.Game); BinaryFormatter formatter = new BinaryFormatter(); game.Player = (Player)formatter.Deserialize(stream); game.Player.newMainRoom(); stream.Close(); mainmenu.setDraw(false); BackToGame(); } else { throw new FileNotFoundException(); } } catch (FileNotFoundException) { MessageBox.Show("No save found"); } catch (SerializationException) { MessageBox.Show("Failed to load, save file corrupted."); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } // Do draw is set to false if load was successful, otherwise it will still be true mainmenu.setUpdate(mainmenu.doDraw()); }