public MenuSystem(SubSystems subsystems) : base(subsystems) { TextFile textfile = GetSubSystem<IO.FileSystem>().OpenTextFile(@"data/system.def"); TextSection info = textfile.GetSection("info"); TextSection files = textfile.GetSection("files"); m_motifname = info.GetAttribute<String>("name", String.Empty); m_motifauthor = info.GetAttribute<String>("author", String.Empty); Dictionary<Int32, Font> fontmap = new Dictionary<Int32, Font>(); Drawing.SpriteSystem spritesystem = GetSubSystem<Drawing.SpriteSystem>(); String fontpath1 = files.GetAttribute<String>("font1", null); if (fontpath1 != null) fontmap[1] = spritesystem.LoadFont(fontpath1); String fontpath2 = files.GetAttribute<String>("font2", null); if (fontpath2 != null) fontmap[2] = spritesystem.LoadFont(fontpath2); String fontpath3 = files.GetAttribute<String>("font3", null); if (fontpath3 != null) fontmap[3] = spritesystem.LoadFont(fontpath3); m_fontmap = new Drawing.FontMap(fontmap); String soundpath = @"data/" + files.GetAttribute<String>("snd"); String spritepath = @"data/" + files.GetAttribute<String>("spr"); String animpath = textfile.Filepath; m_titlescreen = new TitleScreen(this, textfile.GetSection("Title Info"), spritepath, animpath, soundpath); m_titlescreen.LoadBackgrounds("Title", textfile); m_versusscreen = new VersusScreen(this, textfile.GetSection("VS Screen"), spritepath, animpath, soundpath); m_versusscreen.LoadBackgrounds("Versus", textfile); m_selectscreen = new SelectScreen(this, textfile.GetSection("Select Info"), spritepath, animpath, soundpath); m_selectscreen.LoadBackgrounds("Select", textfile); m_combatscreen = new CombatScreen(this); m_replayscreen = new RecordedCombatScreen(this); m_currentscreen = null; m_newscreen = null; m_fade = 0; m_fadespeed = 0; m_eventqueue = new Queue<Events.Base>(); }
void SetScreen(Screen screen) { if (screen == null) throw new ArgumentNullException("screen"); if (m_currentscreen != null) { m_newscreen = screen; PostEvent(new Events.FadeScreen(FadeDirection.Out)); } else { m_currentscreen = screen; PostEvent(new Events.FadeScreen(FadeDirection.In)); } }
void FadeOutScreen(Screen screen) { if (screen == null) throw new ArgumentNullException("screen"); screen.FadingOut(); GetSubSystem<Input.InputSystem>().LoadInputState(); m_fade = 1; m_fadespeed = -screen.FadeOutTime; }
void FadeInScreen(Screen screen) { if (screen == null) throw new ArgumentNullException("screen"); screen.Reset(); screen.FadingIn(); m_fade = 0; m_fadespeed = screen.FadeInTime; }
void FadedOutScreen(Screen screen) { if (screen == null) throw new ArgumentNullException("screen"); screen.FadeOutComplete(); }
void DoFading() { if (m_fadespeed == 0) { GetSubSystem<Video.VideoSystem>().Tint = Color.White; return; } m_fade += 1.0f / m_fadespeed; if (m_fadespeed > 0) { m_fade = Math.Min(1, m_fade); if (m_fade == 1) { m_fadespeed = 0; FadedInScreen(CurrentScreen); } } if (m_fadespeed < 0) { m_fade = Math.Max(0, m_fade); if (m_fade == 0) { m_fadespeed = 0; FadedOutScreen(CurrentScreen); if (m_newscreen != null) { m_currentscreen = m_newscreen; m_newscreen = null; FadeInScreen(CurrentScreen); } } } GetSubSystem<Video.VideoSystem>().Tint = new Color(new Vector4(m_fade, m_fade, m_fade, m_fade)); }