protected MenuUIManager(IMenuController menuController) { MenuRoot = UI.Root; MenuRoot.SetDefaultStyle(Game.PackageManager.GetXmlFile("UI/MainMenuStyle.xml", true)); this.MenuController = menuController; MainMenu = new MainMenu(this); OptionsScreen = new OptionsScreen(this); PauseMenu = new PauseMenu(this); LoadingScreen = new LoadingScreen(this); SaveGameScreen = new SaveGameScreen(this); LoadGameScreen = new LoadGameScreen(this); PackagePickingScreen = new PackagePickingScreen(this); LevelPickingScreen = new LevelPickingScreen(this); LevelSettingsScreen = new LevelSettingsScreen(this); LevelCreationScreen = new LevelCreationScreen(this); SaveAsScreen = new SaveAsScreen(this); EndScreen = new EndScreen(this); AboutScreen = new AboutScreen(this); FileBrowsingPopUp = new FileSystemBrowsingPopUp(this); ConfirmationPopUp = new ConfirmationPopUp(this); ErrorPopUp = new ErrorPopUp(this); PreviousScreens = new Stack <MenuScreen>(); }
/// <summary> /// Loads the screen layout and contents /// </summary> /// <param name="proxy"></param> /// <param name="baseDir"></param> /// <param name="startingRelativePath"></param> /// <param name="selectOptions"></param> /// <param name="taskCompletition"></param> /// <exception cref="ArgumentException">baseDir or startingRelativePath were wrong</exception> /// <exception cref="PathTooLongException"></exception> public Screen(FileSystemBrowsingPopUp proxy, string baseDir, string startingRelativePath, SelectOption selectOptions, TaskCompletionSource <IPathResult> taskCompletition) { this.proxy = proxy; this.baseDir = baseDir; this.selectOptions = selectOptions; this.taskCompletition = taskCompletition; this.cDirEntries = new List <NameTextPair>(); Game.UI.LoadLayoutToElement(MenuUIManager.MenuRoot, Game.ResourceCache, "UI/FileBrowserLayout.xml"); window = (Window)MenuUIManager.MenuRoot.GetChild("FileBrowserWindow"); window.BringToFront(); pathEdit = (LineEdit)window.GetChild("PathEdit", true); selectButton = (Button)window.GetChild("SelectButton", true); backButton = (Button)window.GetChild("BackButton", true); fileView = (ListView)window.GetChild("FileView", true); pathEdit.TextChanged += PathChanged; fileView.ItemSelected += OnItemSelected; fileView.ItemDoubleClicked += OnItemDoubleClicked; selectButton.Released += SelectButtonPressed; backButton.Released += BackButtonReleased; Game.Input.KeyDown += KeyDown; if (!string.IsNullOrEmpty(startingRelativePath)) { try { currentDirectory = Path.GetDirectoryName(startingRelativePath); currentFileName = Path.GetFileName(startingRelativePath); } catch (ArgumentException) { Dispose(); throw; } catch (PathTooLongException) { Dispose(); throw; } } else { currentDirectory = ""; currentFileName = ""; } if (!LoadDirectory(currentDirectory)) { Dispose(); throw new ArgumentException("Invalid starting directory or baseDir path"); } pathEdit.Text = Path.Combine(currentDirectory, currentFileName); DisableSelectButton(); CurrentDirSelected(); }