private void UpdateWindowContents(ModernMUD.Screen screen) { textBox1.Text = screen.Contents; try { cbScreenType.SelectedIndex = (int)screen.Type; } catch { // whatever, who cares? } txtName.Text = screen.Name; chkEnabled.Checked = screen.Active; }
/// <summary> /// Shows a Screen to the player. /// </summary> /// <param name="screen"></param> public void ShowScreen( Screen screen ) { if (screen == null || String.IsNullOrEmpty(screen.Contents)) { return; } WriteToBuffer( screen.Contents ); }
/// <summary> /// Loads a screen file from disk. /// </summary> /// <param name="filename"></param> /// <returns></returns> public static bool Load(string filename, string blankFilename = null) { ScreenList.Clear(); _introScreenColor = null; _introScreenMonochrome = null; _mainMenuScreen = null; _raceSelectionScreenColor = null; _raceSelectionScreenMonochrome = null; XmlTextReader xtr = null; try { // This method of serialization will preserve newline characters in the text. // This is different from most of what we have done in other parts of Basternae. XmlSerializer serializer = new XmlSerializer(typeof(List<Screen>)); try { xtr = new XmlTextReader(new StreamReader(filename)); } catch (FileNotFoundException) { if (!String.IsNullOrEmpty(blankFilename)) { File.Copy(blankFilename, filename); xtr = new XmlTextReader(new StreamReader(filename)); } else { throw; } } ScreenList = serializer.Deserialize(xtr) as List<Screen>; xtr.Close(); if( ScreenList == null ) { throw new Exception("Unable to load intro, menu, and race selection screens. Does file exist and contain valid data?"); } foreach( Screen scrn in ScreenList ) { if (scrn._active) { switch (scrn._type) { case ScreenType.intro: _introScreenColor = scrn; break; case ScreenType.menu: _mainMenuScreen = scrn; break; case ScreenType.races: _raceSelectionScreenColor = scrn; break; case ScreenType.monochrome_intro: _introScreenMonochrome = scrn; break; case ScreenType.monochrome_races: _raceSelectionScreenMonochrome = scrn; break; } } } if( _introScreenColor == null ) Console.WriteLine("Color intro screen not found."); if( _mainMenuScreen == null ) Console.WriteLine("Main menu not found."); if( _raceSelectionScreenColor == null ) Console.WriteLine("Color race selection screen not found."); if( _introScreenMonochrome == null ) Console.WriteLine("Monochrome intro screen not found."); if( _raceSelectionScreenMonochrome == null ) Console.WriteLine("Monochrome race selection screen not found."); return true; } catch( Exception ex ) { Console.WriteLine("Exception in Screen.Load(): " + ex); ScreenList = new List<Screen>(); return false; } }