public void onClick() { canvasGameObject = GameObject.Find("Canvas"); MenuRoot menuScript = canvasGameObject.GetComponent <MenuRoot>(); menuScript.showMenu("Credits Root"); }
public static void Init(string name, string header) { if (Instance == null) { Instance = new MenuRoot(name, header); } }
public void onClick() { MenuRoot = GameObject.Find("Canvas"); MenuRoot menuScript = MenuRoot.GetComponent <MenuRoot>(); menuScript.showMenu("Load Game Root"); }
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>(); }
public void CalculateSumsTest_SingleMenuSingleItemLabel() { //Arrange Item testItem = new Item() { ID = 5, Label = "test" }; List <Item> testItems = new List <Item>() { testItem }; MenuNode testMenuNode = new MenuNode() { Items = testItems }; MenuRoot testMenuRoot = new MenuRoot { Menu = testMenuNode }; List <MenuRoot> fileContents = new List <MenuRoot> { testMenuRoot }; //Act var actual = Program.CalculateSums(fileContents); //Assert var expected = 5; var expectedCount = 1; Assert.AreEqual(expectedCount, actual.Count()); Assert.AreEqual(expected, actual.ElementAt(0)); }
public MenuTree() { root = new MenuRoot(); root.name = "root"; root.tree = this; _nodes = new List <MenuTrunk>(); _nodes.Add(root); }
public void CalculateSumsTest_MultiMenuMultiItemSomeLabel() { //Arrange Item testItem = new Item() { ID = 5, Label = "test" }; List <Item> testItems = new List <Item>() { testItem }; MenuNode testMenuNode = new MenuNode() { Items = testItems }; MenuRoot testMenuRoot = new MenuRoot { Menu = testMenuNode }; Item testItem2 = new Item() { ID = 10 }; Item testItem3 = new Item() { ID = 15, Label = "test3" }; List <Item> testItems2 = new List <Item>() { testItem2, testItem3 }; MenuNode testMenuNode2 = new MenuNode() { Items = testItems2 }; MenuRoot testMenuRoot2 = new MenuRoot { Menu = testMenuNode2 }; List <MenuRoot> fileContents = new List <MenuRoot> { testMenuRoot, testMenuRoot2 }; //Act var actual = Program.CalculateSums(fileContents); //Assert var expected = 5; var expected2 = 15; var expectedCount = 2; Assert.AreEqual(expectedCount, actual.Count()); Assert.AreEqual(expected, actual.ElementAt(0)); Assert.AreEqual(expected2, actual.ElementAt(1)); }
public void asType_WithValidJson_ReturnsMenus() { List <MenuRoot> expected = new List <MenuRoot>(); MenuRoot root = new MenuRoot(); Menu menu = new Menu(); root.menu = menu; MenuItem item = new MenuItem(); item.id = 27; MenuItem item1 = new MenuItem(); item1.id = 0; item1.label = "Label 0"; MenuItem[] items = new MenuItem[3]; items[0] = item; items[1] = item1; items[2] = null; menu.header = "menu"; menu.items = items; expected.Add(root); string json = ""; using (StreamReader sr = new StreamReader(@"Resources\test.json")) { json = sr.ReadToEnd(); } List <MenuRoot> menus = (List <MenuRoot>)JsonService.asType(json, typeof(List <MenuRoot>)); Assert.AreEqual(expected[0].menu.header, menus[0].menu.header); Assert.AreEqual(expected[0].menu.items[0].id, menus[0].menu.items[0].id); Assert.AreEqual(expected[0].menu.items[0].label, menus[0].menu.items[0].label); Assert.AreEqual(expected[0].menu.items[1].id, menus[0].menu.items[1].id); Assert.AreEqual(expected[0].menu.items[1].label, menus[0].menu.items[1].label); Assert.AreEqual(expected[0].menu.items[2], menus[0].menu.items[2]); }
public void CalculateSumsTest_SingleMenuNullItems() { //Arrange List <Item> testItems = null; MenuNode testMenuNode = new MenuNode() { Items = testItems }; MenuRoot testMenuRoot = new MenuRoot { Menu = testMenuNode }; List <MenuRoot> fileContents = new List <MenuRoot> { testMenuRoot }; //Act var actual = Program.CalculateSums(fileContents); //Assert Assert.IsTrue(!actual.Any()); }
public void ChangeGameState(EGameState _state) { if (GameState == _state) { return; } GameState = _state; switch (GameState) { case EGameState.GS_Game: MenuRoot.SetActive(false); GameRoot.SetActive(true); break; case EGameState.GS_Menu: GameRoot.SetActive(false); MenuRoot.SetActive(true); break; } }
private void CreateMenu() { //File MenuViewModel fileMenu = new MenuViewModel("_File"); fileMenu.AddChild(new MenuViewModel("Update _Editions Database...", new RelayCommand(UpdateDatabaseCommandExecute))); fileMenu.AddChild(new MenuViewModel("Update _Rules Database..", new RelayCommand(UpdateRulesDatabaseCommandExecute))); fileMenu.AddChild(new MenuViewModel("Update _Images Database..", new RelayCommand(UpdateImageDatabaseCommandExecute))); //Not Allowed in release version, the update is done by copy of referential #if DEBUG fileMenu.AddChild(new MenuViewModel("Update _Preconstructed Decks Database..", new RelayCommand(UpdatePreconstructedDeckCommandExecute))); #endif fileMenu.AddChild(MenuViewModel.Separator()); //Price MenuViewModel priceMenu = new MenuViewModel("Update _Prices Database"); foreach (PriceSource pricesource in (PriceSource[])Enum.GetValues(typeof(PriceSource))) { priceMenu.AddChild(new MenuViewModel(pricesource.ToString("g"), new RelayCommand(UpdatePriceDatabaseCommandExecute), pricesource)); } fileMenu.AddChild(priceMenu); fileMenu.AddChild(MenuViewModel.Separator()); fileMenu.AddChild(new MenuViewModel("Search...", new RelayCommand(SearchCommandExecute))); fileMenu.AddChild(MenuViewModel.Separator()); fileMenu.AddChild(new MenuViewModel("_Exit", new RelayCommand(CloseCommandExecute))); MenuRoot.AddChild(fileMenu); //Collection _collectionViewModel = new MenuViewModel("_Collection"); GenerateCollectionMenu(); MenuRoot.AddChild(_collectionViewModel); //Database Management MenuViewModel dbManagementMenu = new MenuViewModel("_Database Management"); dbManagementMenu.AddChild(new MenuViewModel("_Audit", new RelayCommand(AuditCommandExecute))); dbManagementMenu.AddChild(MenuViewModel.Separator()); MenuViewModel updateTableMenu = new MenuViewModel("_Update table"); dbManagementMenu.AddChild(updateTableMenu); MenuRoot.AddChild(dbManagementMenu); //Database Management/Update table updateTableMenu.AddChild(new MenuViewModel("_Block", new RelayCommand(BlockModificationCommandExecute))); updateTableMenu.AddChild(new MenuViewModel("_Edition", new RelayCommand(EditionModificationCommandExecute))); updateTableMenu.AddChild(new MenuViewModel("_Language", new RelayCommand(LanguageModificationCommandExecute))); updateTableMenu.AddChild(new MenuViewModel("_Translate", new RelayCommand(TranslateModificationCommandExecute))); //Tools MenuViewModel toolsMenu = new MenuViewModel("_Tools"); toolsMenu.AddChild(new MenuViewModel("_Options", new RelayCommand(OptionCommandExecute))); toolsMenu.AddChild(MenuViewModel.Separator()); toolsMenu.AddChild(new MenuViewModel("_Check for new version", new RelayCommand(CheckNewVersionCommandExecute))); if (_magicDatabase.PictureDatabaseMigration.CouldMigrate) { toolsMenu.AddChild(MenuViewModel.Separator()); toolsMenu.AddChild(new MenuViewModel("_Migrate pictures database images", new RelayCommand(MigrationPictureDatabaseCommandExecute))); } MenuRoot.AddChild(toolsMenu); //? MenuViewModel aboutMenu = new MenuViewModel("?"); aboutMenu.AddChild(new MenuViewModel("_Version", new RelayCommand(VersionCommandExecute))); MenuRoot.AddChild(aboutMenu); GenerateContextMenu(); }
public MenuTree() { _root = new MenuRoot("root", null, this); _nodes = new List <MenuTrunk>(); _nodes.Add(_root); }
public MenuGeneratorModel(IOptionsSnapshot <MenuRoot> menuRoot) { _menuRoot = menuRoot.Value; }
public MenuGeneratorModel(IOptionsSnapshot <MenuRoot> menuRoot, IConfiguration configuration) { _menuRoot = menuRoot.Value; _conn = configuration.GetConnectionString("Default"); }
private void CreateScene() { AssetDatabase.SaveAssets(); Type.GetType("UnityEditor.LogEntries,UnityEditor.dll") .GetMethod("Clear", BindingFlags.Static | BindingFlags.Public) .Invoke(null, null); newScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Additive); EditorSceneManager.CloseScene(EditorSceneManager.GetSceneAt(0), true); newScene.name = folderName; //GameObject canvasRoot = new GameObject("CanvasRoot"); CreateEventSystem(); GameObject rootObj = CreateCanvas(); menuRoot = rootObj.AddComponent <MenuRoot>(); //menuRoot.allMenus = new Dictionary<string, MenuManager>(); int tempI = 0; string tempFolder = ""; string tempFolderA = ""; string tempFolderDel = ""; while (tempI < 1000) { tempFolder = "assets/" + TEMP_DIR + tempI.ToString(); if (!Directory.Exists(tempFolder)) { tempFolderDel = tempFolder; tempFolderA = tempFolder + "/Resources"; Directory.CreateDirectory(tempFolderA); break; } else { tempI++; } } tempFolderA += "/" + TEMP_SUB_DIR; FileUtil.CopyFileOrDirectory(sceneDirectory, tempFolderA); //FileUtil.CopyFileOrDirectoryFollowSymlinks(sceneDirectory, tempFolderA); AssetDatabase.Refresh(); MenuData[] menus = Resources.LoadAll <MenuData>(TEMP_SUB_DIR); tempMenus = new Dictionary <string, MenuManager>(); tempButtons = new Dictionary <Button, UiData>(); tempUis = new Queue <KeyValuePair <Transform, List <UiSortData> > >(); foreach (MenuData md in menus) { MenuManager menu = (MenuManager)CreateMenu(md, rootObj.transform); menuRoot.AddMenu(menu); tempMenus.Add(md.name, menu); } foreach (KeyValuePair <Button, UiData> bb in tempButtons) { Type[] arguments = new Type[1]; arguments[0] = typeof(int); MethodInfo method = UnityEventBase.GetValidMethodInfo(menuRoot, "ShowMenu", arguments); UnityAction <int> ua = Delegate.CreateDelegate(typeof(UnityAction <int>), menuRoot, method) as UnityAction <int>; if (bb.Value.action == ButtonAction.ShowMenu) { Debug.Log(menuRoot.allMenus.IndexOf(tempMenus[bb.Value.goTo.name])); int index = menuRoot.allMenus.IndexOf(tempMenus[bb.Value.goTo.name]); UnityEventTools.AddIntPersistentListener(bb.Key.onClick, ua, index); } } while (tempUis.Count > 0) { KeyValuePair <Transform, List <UiSortData> > tempK = tempUis.Dequeue(); List <UiSortData> tempList = tempK.Value; for (int i = 0; i < tempList.Count; i++) { //Debug.Log("^^^: " + tempList[i].layer); tempList[i].ui.SetAsFirstSibling(); } } EditorSceneManager.SaveScene(UnityEngine.SceneManagement.SceneManager.GetSceneAt(0), sceneDirectory + "/" + folderName + ".unity"); FileUtil.DeleteFileOrDirectory(tempFolderDel); AssetDatabase.Refresh(); if (myWindow != null) { myWindow.Close(); } return; Debug.Log(":: " + sceneDirectory + ", " + folderName); // You can either filter files to get only neccessary files by its file extension using LINQ. // It excludes .meta files from all the gathers file list. IEnumerable <string> assetFiles = GetFiles(GetSelectedPathOrFallback()).Where(str => str.Contains(".meta") == false); foreach (string f in assetFiles) { Debug.Log("Files: " + f); } }