private static bool Prefix(BasicMenu __instance, int index)
        {
            BasicMenu mainMenu = (BasicMenu)AccessTools.Field(typeof(Panel_MainMenu), "m_BasicMenu")
                                 .GetValue(InterfaceManager.m_Panel_MainMenu);

            // Skip if mod loading failed and button clicked was Story, Sandbox or Challenge
            return(!(__instance == mainMenu && ModLoader.HasFailed() && index < 3));
        }
Esempio n. 2
0
        public static void moveItemTo(this BasicMenu menu, int indexTo, int indexFrom = -1)
        {
            if (indexFrom == -1)
            {
                indexFrom = menu.m_ItemModelList.Count - 1;
            }

            var item = menu.m_ItemModelList[indexFrom];

            menu.m_ItemModelList.RemoveAt(indexFrom);
            menu.m_ItemModelList.Insert(indexTo, item);
        }
Esempio n. 3
0
        private void Start()
        {
            basicMenu = GetComponent <BasicMenu>();

            basicMenu.Menu.CreateMenuEntries(
                MinigameManager.CommunicationBus.MenuEntries);

            subscribe();

            IntermissionPage.SetActive(true);
            MenuUI.SetActive(false);

            StartCoroutine(Delay.StartDelay(2, disableIntermissionPage, null));
        }
        private static void UpdateVisuals(Panel_MainMenu mainMenu)
        {
            BasicMenu basicMenu = mainMenu.m_BasicMenuRoot.GetComponentInChildren <BasicMenu>();

            Transform tldLogo    = mainMenu.m_MainWindow.transform.Find("TLD_wordmark");
            Vector3   targetPos  = tldLogo.localPosition;
            float     menuHeight = basicMenu.GetItemCount() * basicMenu.m_MenuGrid.cellHeight;

            targetPos.y           = menuHeight - 87;
            tldLogo.localPosition = targetPos;

            basicMenu.m_MenuGrid.Reposition();
            Traverse.Create(basicMenu).Field("m_PreviousSelectedButtonIndex").SetValue(-1);
            basicMenu.ManualUpdate();
        }
Esempio n. 5
0
            private static void AddAnotherMenuItem(BasicMenu basicMenu)
            {
                GameObject gameObject = NGUITools.AddChild(basicMenu.m_MenuGrid.gameObject, basicMenu.m_BasicMenuItemPrefab);

                gameObject.name = "ModSettings MenuItem";
                BasicMenuItem item = gameObject.GetComponent <BasicMenuItem>();

                BasicMenu.BasicMenuItemView view = item.m_View;
                int           itemIndex          = basicMenu.m_MenuItems.Count;
                EventDelegate onClick            = new EventDelegate(new Action(() => basicMenu.OnItemClicked(itemIndex)));

                view.m_Button.onClick.Add(onClick);
                EventDelegate onDoubleClick = new EventDelegate(new Action(() => basicMenu.OnItemDoubleClicked(itemIndex)));

                view.m_DoubleClickButton.m_OnDoubleClick.Add(onDoubleClick);
                basicMenu.m_MenuItems.Add(view);
            }
            private static void Postfix(Panel_MainMenu __instance)
            {
                if (!changed)
                {
                    return;
                }

                BasicMenu basicMenu = __instance.m_BasicMenuRoot.GetComponentInChildren <BasicMenu>();

                if (!basicMenu.gameObject.activeInHierarchy)
                {
                    return;
                }

                UpdateVisuals(__instance);
                changed = false;
            }
Esempio n. 7
0
        static void Main(string[] args)
        {
            LoadData();

            while (true)
            {
                int option = MainMenus.ExecuteMenu(BasicMenuPrint, 2);

                if (option == 1)
                {
                    BasicMenu.Menu();
                }
                else if (option == 2)
                {
                    SaveData();
                    break;
                }
            }
        }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        if (basicMenu == null)
        {
            if (CoffeShopMenu.Instance != null)
            {
                basicMenu = CoffeShopMenu.Instance;
            }

            if (BankMenu.Instance != null)
            {
                basicMenu = BankMenu.Instance;
            }

            if (HotelMenu.Instance != null)
            {
                basicMenu = HotelMenu.Instance;
            }
        }
    }
Esempio n. 9
0
            private static void Postfix(Panel_OptionsMenu __instance)
            {
                if (!ModSettingsMenu.HasVisibleModSettings(isMainMenu: InterfaceManager.IsMainMenuActive()))
                {
                    return;
                }

                BasicMenu basicMenu = __instance.m_BasicMenu;

                if (basicMenu == null)
                {
                    return;
                }

                AddAnotherMenuItem(basicMenu);                 // We need one more than they have...
                BasicMenu.BasicMenuItemModel firstItem = basicMenu.m_ItemModelList[0];
                int itemIndex = basicMenu.GetItemCount();

                basicMenu.AddItem("ModSettings", MOD_SETTINGS_ID, itemIndex, "Mod Settings", "Change the configuration of your mods", null,
                                  new Action(() => ShowModSettings(__instance)), firstItem.m_NormalTint, firstItem.m_HighlightTint);
            }
            internal static void Postfix(Panel_OptionsMenu __instance)
            {
                if (!ModComponentMenu.HasVisiblePages())
                {
                    return;
                }

                BasicMenu basicMenu = __instance.m_BasicMenu;

                if (basicMenu is null)
                {
                    return;
                }

                //AddAnotherMenuItem(basicMenu); // We need one more than they have...
                BasicMenu.BasicMenuItemModel firstItem = basicMenu.m_ItemModelList[0];
                int itemIndex = basicMenu.GetItemCount();

                basicMenu.AddItem("ModComponent", MODCOMPONENT_ID, itemIndex, "ModComponent", "View information about ModComponent and your installed item packs.", null,
                                  new Action(() => ShowModComponentMenu(__instance)), firstItem.m_NormalTint, firstItem.m_HighlightTint);
            }
Esempio n. 11
0
        public OptionsMenu()
        {
            AdminUser manager = new AdminUser();

            bool firstChoise = true;
            int  select;

            while (firstChoise)
            {
                bool correctNum = false;
                do
                {
                    Console.WriteLine("1.Application Login\n2.Login As Super Admin\n3.Create Account\n0.Close Application");
                    Console.WriteLine("=================");
                    Console.WriteLine("Select from Menu:");



                    bool isNum = int.TryParse(Console.ReadLine(), out select);
                    if (select < 0 || select > 3)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkYellow;
                        Console.WriteLine("Your choose it's out of range.");
                        Console.ResetColor();
                        break;
                    }
                    else
                    {
                        correctNum = true;
                    }
                } while (!correctNum);

                switch (select)
                {
                case 1:
                    //This bool become true only if username and pass it's correct
                    //otherwise still ask insert username and pass
                    bool c = false;

                    do
                    {
                        string   user = CreateUser("Give", "username");
                        string   pass = CreateUser("Give", "password");
                        AccessId x    = manager.Login(user, pass);
                        if (x != 0 && x != AccessId.Admin)
                        {
                            Console.WriteLine($"Welcome {user}");

                            switch (x)
                            {
                            case AccessId.Simple:
                                SimpleMenu simpleMenu = new SimpleMenu(user);
                                break;

                            case AccessId.Basic:
                                BasicMenu basicMenu = new BasicMenu(user);
                                break;

                            case AccessId.Edit:
                                EditMenu editMenu = new EditMenu(user);
                                break;

                            case AccessId.Delete:
                                DeleteMenu deleteMenu = new DeleteMenu(user);
                                break;
                            }
                            c = true;
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.DarkRed;
                            Console.WriteLine("Your username or password it's incorrect.Try again.");
                            Console.ResetColor();
                        }
                    } while (!c);
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine(String.Format("{0," + Console.WindowWidth / 2 + "}", "Admin Login Form"));
                    string   userAdmin = CreateUser("Give", "username");
                    string   password  = CreateUser("Give", "password");
                    AccessId adm       = manager.Login(userAdmin, password);
                    if (adm == AccessId.Admin)
                    {
                        Console.WriteLine($"Welcome {userAdmin}\n");
                        bool take = false;
                        do
                        {
                            Console.Clear();
                            Console.WriteLine("1.Create a user\n2.View the user of system\n3.Delete a user\n4.Update a user\n0.Log Out");
                            int    val;
                            string email;
                            bool   n = int.TryParse(Console.ReadLine(), out val);
                            switch (val)
                            {
                            case 1:
                                try
                                {
                                    userAdmin = CreateUser("Give", "username");
                                    password  = CreateUser("Give", "password");
                                    email     = CreateUser("Give", "email");
                                    manager.Register(userAdmin, password, email);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    Console.WriteLine("Press any button to exit.");
                                    Console.ReadKey();
                                    return;
                                }

                                break;

                            case 2:
                                manager.ViewUser();
                                break;

                            case 3:
                                try
                                {
                                    int  userId;
                                    bool id = int.TryParse(CreateUser("Give", "user id"), out userId);
                                    User a  = new User()
                                    {
                                        Id = userId
                                    };
                                    manager.DeleteUser(a);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    Console.WriteLine("Press any button to exit.");
                                    Console.ReadKey();
                                    return;
                                }
                                break;

                            case 4:
                                Console.WriteLine("1.Change Password\n2.Change Access id\n3.Change email");
                                int      takeVal, _id;
                                bool     _take = int.TryParse(Console.ReadLine(), out takeVal);
                                string   success, _email;
                                AccessId e;
                                switch (takeVal)
                                {
                                case 1:
                                    try
                                    {
                                        _take    = int.TryParse(CreateUser("Give", "user id"), out _id);
                                        password = CreateUser("Give", "password");
                                        manager.UpdateUser(_id, password);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        Console.WriteLine("Press any button to exit.");
                                        Console.ReadKey();
                                        return;
                                    }

                                    break;

                                case 2:
                                    try
                                    {
                                        bool _successBool = false;
                                        _take = int.TryParse(CreateUser("Give", "user id"), out _id);
                                        do
                                        {
                                            success = CreateUser("Give", "access id");
                                            if (!ValidAccessId(success))
                                            {
                                                Console.WriteLine("Not valid access id");
                                            }
                                            else
                                            {
                                                _successBool = true;
                                            }
                                        } while (!_successBool);
                                        e = (AccessId)Enum.Parse(typeof(AccessId), success);
                                        manager.UpdateUser(_id, e);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        Console.WriteLine("Press any button to exit.");
                                        Console.ReadKey();
                                        return;
                                    }

                                    break;

                                case 3:
                                    try
                                    {
                                        _take  = int.TryParse(CreateUser("Give", "user id"), out _id);
                                        _email = CreateUser("Give", "email");
                                        manager.UpdateEmail(_id, _email);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        Console.WriteLine("Press any button to exit.");
                                        Console.ReadKey();
                                        return;
                                    }
                                    break;
                                }
                                break;

                            case 0:
                                Environment.Exit(0);
                                break;
                            }

                            Console.WriteLine("Do you want to continue?(Y/N)");
                            string answer = Console.ReadLine();

                            if (answer == "Y" || answer == "y")
                            {
                                take = false;
                            }
                            else
                            {
                                take = true;
                                manager.Logout();
                            }
                        } while (!take);
                    }
                    else
                    {
                        Console.WriteLine("You enter invalid details!");
                        Environment.Exit(0);
                    }

                    break;

                case 3:
                    string usernameOne, passOne, emailOne;
                    bool   first  = false;
                    bool   second = false;
                    bool   third  = false;

                    do
                    {
                        usernameOne = CreateUser("Give", "username").Trim();
                        var x = manager.ExistUser(usernameOne);
                        if (!x)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine("The username already exist.");
                            Console.ResetColor();
                        }
                        else if (usernameOne == "" || usernameOne.Length < 6 || usernameOne.Length > 12 || !x)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine("The username must be between 6 and 12 characters.");
                            Console.ResetColor();
                            first = false;
                        }
                        else
                        {
                            first = true;
                        }
                    } while (!first);

                    do
                    {
                        passOne = CreateUser("Give", "password");
                        bool isValidPass = Regex.IsMatch(passOne, passPattern);
                        if (!isValidPass)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine("The password must contain between 8 and 15 characters." +
                                              "Also must contain 2 letters,one special character and one number.");
                            Console.ResetColor();
                            second = false;
                        }
                        else
                        {
                            second = true;
                        }
                    } while (!second);

                    do
                    {
                        emailOne = CreateUser("Give", "email").Trim();
                        bool isValidEmail = Regex.IsMatch(emailOne, emailPattern);
                        if (!isValidEmail)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine("The email doesn't have the correct format.");
                            Console.ResetColor();
                        }
                        else
                        {
                            third = true;
                        }
                    } while (!third);

                    try
                    {
                        bool p = manager.Register(usernameOne, passOne, emailOne);
                        if (p)
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.WriteLine("Your account create succesfully.");
                            Console.ResetColor();
                            Console.WriteLine($"Your username: {usernameOne}");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine("Press any button to exit.");
                        Console.ReadKey();
                        return;
                    }

                    Console.WriteLine("Do you want to continue? Y/N");
                    string yourChoose = Console.ReadLine();
                    if (yourChoose == "Y" || yourChoose == "y")
                    {
                        firstChoise = true;
                    }
                    else
                    {
                        firstChoise = false;
                        manager.Logout();
                    }
                    break;

                case 0:
                    Environment.Exit(0);
                    break;
                }
            }
            Console.ReadKey();
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            //*** Initialize Menus ***
            //************************
            SelectorMenu Menu1 = new SelectorMenu();
            SelectorMenu Menu2 = new SelectorMenu(ConsoleColor.Black, ConsoleColor.Green);
            SelectorMenu Menu3 = new SelectorMenu(" \u03A9 ");

            Menu3.Selector.BackgroundColor = ConsoleColor.Black;
            Menu3.Selector.ForegroundColor = ConsoleColor.Red;
            SelectorMenu Menu4     = new SelectorMenu();
            BasicMenu    MenuBasic = new BasicMenu();

            //*** Build Menus ***
            //*******************
            Menu1
            .AddItem("Does Nothing")
            .AddItem("GoTo A Message", () => Menu1.GoTo("Press any key: go back."))
            .AddItem("GoTo A Message, then arrive at Menu2", () => Menu2.GoTo("Press any key: go to Menu2"))
            .AddItem("GoTo Menu2 (Expecting Green Text)", () => Menu2.GoTo())
            .AddItem("GoTo Menu3 (Swap Testing)", () => Menu3.GoTo())
            .AddItem("GoTo Menu4 (Multi-Line Bar Testing)", () => Menu4.GoTo())
            .AddItem("GoTo MenuBasic (Is BasicMenu)", () => MenuBasic.GoTo())
            .AddItem("EXIT", () => SelectorMenu.Exit());

            Menu2
            .AddItem(
                label: "A) I'm the real option",
                action: () => { })
            .AddItem(
                label: "B) No I'm the real option",
                action: () => { })
            .AddBar()
            .AddItem(
                label: "C) Uh...",
                action: () =>
            {
                Menu2.GoTo("I'm the real option?");
            })
            .AddItem(
                label: "GoTo Menu1",
                action: () => Menu1.GoTo())
            .AddItem(
                label: "GoTo Menu3",
                action: () => Menu3.GoTo())
            .AddItem(
                label: "EXIT",
                action: () => SelectorMenu.Exit());

            Menu3
            .AddItem("A) Menu3 Option1", delegate() { })
            .AddItem("B) Menu3 Option2", delegate() { })
            .AddItem("C) Menu3 Option3", delegate() { })
            .AddItem("D) Swap Options \"B\" and \"D\"", delegate() { Menu3.Swap(3, 1); })
            .AddBar()
            .AddItem("GoTo Menu1", delegate() { Menu1.GoTo(); })
            .AddItem("GoTo Menu2", delegate() { Menu2.GoTo(); })
            .AddItem("GoTo Menu4", delegate() { Menu4.GoTo(); })
            .AddItem("EXIT", delegate() { SelectorMenu.Exit(); });

            Menu4
            .AddItem("Option1) Be Bill Nye", delegate() { Menu4.GoTo("He's the science guy."); })
            .AddItem("Option2) Be Bill Murray", delegate() { Menu4.GoTo("He's an actor"); })
            .AddItem("Option3) Be Bill Gates", delegate() { Menu4.GoTo("Microsoft. Enough said..."); })
            .AddItem("Option4) Be Bill (the overly generic person)", delegate() { Menu4.GoTo("Hi guys."); })
            .AddBar("-----------------------------\n-----------------------------\n-----------------------------")
            .AddItem("GoTo Menu1", delegate() { Menu1.GoTo(); })
            .AddItem("GoTo Menu2", delegate() { Menu2.GoTo(); })
            .AddItem("GoTo Menu3", delegate() { Menu3.GoTo(); })
            .AddItem("Exit", delegate() { SelectorMenu.Exit(); });

            MenuBasic
            .AddItem("GoTo Menu1", () => Menu1.GoTo())
            .AddItem("GoTo Menu2", () => Menu2.GoTo())
            .AddBar("###########################################################\n" +
                    "#### (Bar Testing) Bars Don't Break Menu Item Selection ###\n" +
                    "###########################################################")
            .AddItem("GoTo Menu3", () => Menu3.GoTo())
            .AddItem("GoTo Menu4", () => Menu4.GoTo())
            .AddBar()
            .AddItem("Exit", () => Menu.Exit());

            //*** Show Starting Menu ***
            //**************************
            Menu1.GoTo();

            //*** Console Exit Code ***
            //*************************

            /* Note:
             * If the menu was started by an actual program, then
             * control will be returned to that program; Action won't be
             * required.
             */
            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }