Пример #1
0
        protected void GotoElementSamples(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);

            tb.Title = "Element Samples";

            var section = new TableViewSection(tb.Source);

            section.Header = "Sample Elements";

            section.Add(new ButtonElement("Button"));
            section.Add(new StringElement("String")
            {
                Command = this.UpdateText
            });
            section.Add(new SubtitleStringElement("Subtitle String", "Subtitle"));
            section.Add(new Value1StringElement("Value1 String", "Detail"));
            section.Add(new Value2StringElement("Value2 String", "Detail"));
            section.Add(new BooleanElement("Boolean", true));
            section.Add(new CheckboxElement("Checkbox", true));
            section.Add(new TextInputElement("Text Input", "")
            {
                Placeholder = "Placeholder text"
            });
            section.Add(new PasswordInputElement("Password"));
            section.Add(new DateInputElement("Date", DateTime.Today));

            // Use a DataViewWrapper to wrap an element with a different view definition from the one it would normally get
            var wrapper = new ElementDataViewWrapper(DefaultElementViewDefintions.DisclosureElementViewDefintion, new StringElement("Wrapped String"));

            section.Add(wrapper);


            this.rootController.PushViewController(tb, true);
        }
Пример #2
0
        protected void DoDomainTest2(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);

            tb.Title = "Snapshot Sourced";

            var section1 = new TableViewSection(tb.Source);

            section1.Header = "commands";
            section1.Add(new StringElement("Test Command 1")
            {
                Command = (x) => SnapshotSamples.DoTest1()
            });
            section1.Add(new StringElement("Test Command 2")
            {
                Command = (x) => SnapshotSamples.DoTest2()
            });

            var adminSection = new TableViewSection(tb.Source);

            adminSection.Header = "Sql";
            adminSection.Add(new StringElement("Browse")
            {
                Command = (x) =>
                {
                    var admin = new SQLite.MonoTouchAdmin.SQLiteAdmin(SnapshotSourcedDB.Main);
                    this.rootController.PushViewController(admin.NewTablesViewController(), true);
                }
            });

            this.rootController.PushViewController(tb, true);
        }
Пример #3
0
    //function used to create the TableViewController
    void CreateTableViews(TableModel tbParam)
    {
        TableViewController tvc = Instantiate(tvcPrefab.gameObject, transform.position, transform.rotation).GetComponent <TableViewController>();

        tvc.transform.SetParent(transform);
        tvc.transform.localScale = Vector3.one;
        tvc.Initialize(tbParam);
    }
Пример #4
0
 /// <inheritdoc/>
 public void BindToNative(object nativeView, BindOptions options = BindOptions.None)
 {
     UnbindFromNative();
     tcontroller = nativeView as TableViewController;
     if (tcontroller == null)
     {
         throw new Exception("Cannot bind Form to " + nativeView);
     }
     tcontroller.Title = root.Text;
     WithTV(SetDelegates);
 }
Пример #5
0
        private void InitSamples()
        {
            this.controller     = new UINavigationController();
            this.monokitSamples = new Samples(this.controller);

            this.window.AddSubview(this.controller.View);

            // setup main index
            this.tableController       = new TableViewController(UITableViewStyle.Grouped);
            this.tableController.Title = "MonoKit";
            this.controller.PushViewController(this.tableController, false);
            this.monokitSamples.SetupMainIndexSection(this.tableController.Source);

            this.window.MakeKeyAndVisible();
        }
Пример #6
0
        protected void GotoGCTests(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);

            tb.Title = "GC Tests";

            var section1 = new TableViewSection(tb.Source);

            section1.Add(new StringElement("Self Referencing Items")
            {
                Command = this.SelfReferencingItemsTest
            });

            this.rootController.PushViewController(tb, true);
        }
Пример #7
0
        protected void GotoLargeDataSample(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);

            tb.Title = "Large Data Sample";

            var section1 = new TableViewSection(tb.Source);

            section1.Header = "1000 Items";

            for (int i = 0; i < 1000; i++)
            {
                section1.Add(new StringElement("String Element " + i.ToString()));
            }

            this.rootController.PushViewController(tb, true);
        }
Пример #8
0
        private void InitSamples()
        {
            this.controller     = new MyNavigationController();
            this.monokitSamples = new Samples(this.controller);

            // create a new window instance based on the screen size
            this.window = new UIWindow(UIScreen.MainScreen.Bounds);

            // setup main index
            this.tableController       = new TableViewController(UITableViewStyle.Grouped);
            this.tableController.Title = "MonoKit";
            this.controller.PushViewController(this.tableController, false);
            this.monokitSamples.SetupMainIndexSection(this.tableController.Source);

            this.window.RootViewController = this.controller;
            this.window.MakeKeyAndVisible();
        }
Пример #9
0
        protected void GotoBindingSamples(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);

            tb.Title = "Binding Samples";

            var section1 = new TableViewSection(tb.Source);

            section1.Header = "Same element";
            section1.Footer = "Note that both elements update";

            var boolElement = new BooleanElement("Bool Value", false);

            section1.Add(boolElement);
            section1.Add(boolElement);

            this.rootController.PushViewController(tb, true);
        }
Пример #10
0
        protected void GotoBindToSingleObject(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);

            tb.Title = "Single Object Binding Sample";

            var section1 = new TableViewSection(tb.Source);

            section1.Add(new TextInputElement(this.bindToSingleObjectPersion, null, new Binding("FirstName"))
            {
                Placeholder = "First Name"
            });
            section1.Add(new TextInputElement(this.bindToSingleObjectPersion, null, new Binding("LastName"))
            {
                Placeholder = "Last Name"
            });
            section1.Add(new DateInputElement(this.bindToSingleObjectPersion, null, new Binding("Birthdate")));

            this.rootController.PushViewController(tb, true);
        }
Пример #11
0
        protected void GotoCustomControl(Element element)
        {
            var tb = new TableViewController(UITableViewStyle.Grouped);

            tb.Title = "Custom Control";

            var section1 = new TableViewSection(tb.Source);

            section1.Header = "Custom Control";

            var view = new UIViewDefinition <CustomElementTableViewCell, StringElement>(DefaultElementViewDefintions.SimpleElementBinding)
            {
                Param = UITableViewCellStyle.Default
            };


            var customData = new StringElement("");
            var wrapper    = new ElementDataViewWrapper(view, customData);

            section1.Add(wrapper);

            this.rootController.PushViewController(tb, true);
        }
Пример #12
0
        public static void Init()
        {
            if (Instance == null)
            {
                try
                {
                    Instance = BeatSaberUI.CreateCustomMenu <CustomMenu>("Multiplayer Lobby");

                    CustomViewController middleViewController = BeatSaberUI.CreateViewController <CustomViewController>();
                    ListViewController   leftViewController   = BeatSaberUI.CreateViewController <ListViewController>();
                    rightViewController = BeatSaberUI.CreateViewController <TableViewController>();

                    Instance.SetMainViewController(middleViewController, true, (firstActivation, type) =>
                    {
                        if (firstActivation)
                        {
                            try
                            {
                                Button host = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f), new Vector2(25f, 7f));
                                host.SetButtonTextSize(3f);
                                host.ToggleWordWrapping(false);
                                host.SetButtonText("Disconnect");
                                host.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        SteamAPI.Disconnect();
                                        Instance.Dismiss();
                                        MultiplayerListing.Instance.Present();
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                float offs = 0;
                                offs      += 10f;
                                Button vc  = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - offs), new Vector2(25f, 7f));
                                vc.SetButtonTextSize(3f);
                                vc.ToggleWordWrapping(false);
                                vc.SetButtonText(Controllers.PlayerController.Instance.VoipEnabled ? "Disable Voice Chat" : "Enable Voice Chat");
                                vc.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        if (!Controllers.PlayerController.Instance.VoipEnabled)
                                        {
                                            vc.SetButtonText("Disable Voice Chat");
                                            Controllers.PlayerController.Instance.VoipEnabled = true;
                                            SteamUser.StartVoiceRecording();
                                        }
                                        else
                                        {
                                            vc.SetButtonText("Enable Voice Chat");
                                            Controllers.PlayerController.Instance.VoipEnabled = false;
                                            SteamUser.StopVoiceRecording();
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                var t        = middleViewController.CreateText("You can use Online Lobby in the Main Menu to choose songs for your lobby. \n\nYou can also control all the default Game Modifiers for the lobby through the Online Lobby Menu as well.", new Vector2(0, BASE.y - 10f));
                                var tt       = middleViewController.CreateText("If something goes wrong, click the disconnect button above and just reconnect to the lobby.", new Vector2(0, 0 - BASE.y));
                                t.alignment  = TMPro.TextAlignmentOptions.Center;
                                tt.alignment = TMPro.TextAlignmentOptions.Center;
                            } catch (Exception e)
                            {
                                Data.Logger.Error(e);
                            }

                            /*   Button g = middleViewController.CreateUIButton("CreditsButton", new Vector2(0, 0), new Vector2(25f, 25f));
                             * g.SetButtonTextSize(7f);
                             * g.ToggleWordWrapping(false);
                             * g.SetButtonText("Select a Song");
                             * g.onClick.AddListener(delegate {
                             *     try
                             *     {
                             *         if (SteamAPI.IsHost())
                             *         {
                             *             SteamAPI.SetSong("112D7FA45FA06F36FF41029099E95B98", "TaKillYa");
                             *             SteamAPI.SetDifficulty((byte)2);
                             *             SteamAPI.RequestPlay(new GameplayModifiers(new GameplayModifiers()));
                             *         }
                             *     }
                             *     catch (Exception e)
                             *     {
                             *         Logger.Error(e);
                             *     }
                             * });*/
                        }
                    });
                    Instance.SetLeftViewController(leftViewController, false, (firstActivation, type) =>
                    {
                        if (firstActivation)
                        {
                            refreshFriendsList(leftViewController);
                            leftViewController.CreateText("Invite Friends", new Vector2(BASE.x + 62.5f, BASE.y));

                            Button b = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, BASE.y + 2.5f), new Vector2(25f, 7f));
                            b.SetButtonText("Refresh");
                            b.SetButtonTextSize(3f);
                            b.ToggleWordWrapping(false);
                            b.onClick.AddListener(delegate()
                            {
                                refreshFriendsList(leftViewController);
                            });


                            invite = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, 0 - BASE.y + 2.5f), new Vector2(25f, 7f));
                            invite.SetButtonText("Invite");
                            invite.SetButtonTextSize(3f);
                            invite.ToggleWordWrapping(false);
                            invite.interactable = false;
                            invite.onClick.AddListener(delegate()
                            {
                                if (selectedPlayer > 0)
                                {
                                    SteamAPI.InviteUserToLobby(new CSteamID(selectedPlayer));
                                }
                            });
                        }
                    });
                    Instance.SetRightViewController(rightViewController, false, (active, type) => {
                        if (active)
                        {
                            rightViewController.CreateText("Lobby Leaderboard", new Vector2(BASE.x + 62.5f, BASE.y));
                        }
                        RefreshScores();
                    });
                } catch (Exception e)
                {
                    Data.Logger.Error(e);
                }
            }
        }
Пример #13
0
 /// <inheritdoc/>
 public void UnbindFromNative()
 {
     WithTV(RemoveDelegates);
     tcontroller = null;
 }
Пример #14
0
        public static void Init()
        {
            if (Instance == null)
            {
                try
                {
                    Instance = BeatSaberUI.CreateCustomMenu <CustomMenu>("Multiplayer Lobby");

                    CustomViewController middleViewController = BeatSaberUI.CreateViewController <CustomViewController>();
                    ListViewController   leftViewController   = BeatSaberUI.CreateViewController <ListViewController>();
                    rightViewController = BeatSaberUI.CreateViewController <TableViewController>();

                    Instance.SetMainViewController(middleViewController, true, (firstActivation, type) =>
                    {
                        if (firstActivation)
                        {
                            try
                            {
                                Button host = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f), new Vector2(25f, 7f));
                                host.SetButtonTextSize(3f);
                                host.ToggleWordWrapping(false);
                                host.SetButtonText("Disconnect");
                                host.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        SteamAPI.Disconnect();
                                        Instance.Dismiss();
                                        MultiplayerListing.Instance.Present();
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                float offs = 0;
                                offs      += 10f;
                                Button vc  = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - offs), new Vector2(25f, 7f));
                                vc.SetButtonTextSize(3f);
                                vc.ToggleWordWrapping(false);
                                vc.SetButtonText(VoiceChatWorker.VoipEnabled ? "Disable Voice Chat" : "Enable Voice Chat");
                                vc.onClick.AddListener(delegate
                                {
                                    try
                                    {
                                        if (!VoiceChatWorker.VoipEnabled)
                                        {
                                            vc.SetButtonText("Disable Voice Chat");
                                            VoiceChatWorker.VoipEnabled = true;
                                            SteamUser.StartVoiceRecording();
                                        }
                                        else
                                        {
                                            vc.SetButtonText("Enable Voice Chat");
                                            VoiceChatWorker.VoipEnabled = false;
                                            SteamUser.StopVoiceRecording();
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Logger.Error(e);
                                    }
                                });
                                offs  += 10f;
                                rejoin = middleViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x, BASE.y + 2.5f - offs), new Vector2(25f, 7f));
                                rejoin.SetButtonTextSize(3f);
                                rejoin.ToggleWordWrapping(false);
                                rejoin.SetButtonText("Re-Join Song");
                                rejoin.interactable = false;
                                rejoin.onClick.AddListener(delegate
                                {
                                    if (SteamAPI.GetLobbyData().Screen == LobbyPacket.SCREEN_TYPE.IN_GAME && SteamAPI.GetLobbyData().CurrentSongOffset > 0f)
                                    {
                                        WaitingMenu.autoReady             = true;
                                        WaitingMenu.timeRequestedToLaunch = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
                                        WaitingMenu.Instance.Present();
                                    }
                                });
                                bodyText           = middleViewController.CreateText("You can use Online Lobby in the Main Menu to choose songs for your lobby. \n\nYou can also control all the default Game Modifiers for the lobby through the Online Lobby Menu as well.", new Vector2(0, BASE.y - 10f));
                                var tt             = middleViewController.CreateText("If something goes wrong, click the disconnect button above and just reconnect to the lobby.", new Vector2(0, 0 - BASE.y));
                                bodyText.alignment = TMPro.TextAlignmentOptions.Center;
                                tt.alignment       = TMPro.TextAlignmentOptions.Center;
                            } catch (Exception e)
                            {
                                Logger.Error(e);
                            }
                        }
                    });
                    Instance.SetLeftViewController(leftViewController, false, (firstActivation, type) =>
                    {
                        if (firstActivation)
                        {
                            refreshFriendsList(leftViewController);
                            leftViewController.CreateText("Invite Friends", new Vector2(BASE.x + 62.5f, BASE.y));

                            Button b = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, BASE.y + 2.5f), new Vector2(25f, 7f));
                            b.SetButtonText("Refresh");
                            b.SetButtonTextSize(3f);
                            b.ToggleWordWrapping(false);
                            b.onClick.AddListener(delegate()
                            {
                                refreshFriendsList(leftViewController);
                            });


                            invite = leftViewController.CreateUIButton("CreditsButton", new Vector2(BASE.x + 80f, 0 - BASE.y + 2.5f), new Vector2(25f, 7f));
                            invite.SetButtonText("Invite");
                            invite.SetButtonTextSize(3f);
                            invite.ToggleWordWrapping(false);
                            invite.interactable = false;
                            invite.onClick.AddListener(delegate()
                            {
                                if (selectedPlayer > 0)
                                {
                                    SteamAPI.InviteUserToLobby(new CSteamID(selectedPlayer));
                                }
                            });
                        }
                    });
                    Instance.SetRightViewController(rightViewController, false, (firstActivation, type) => {
                        if (firstActivation)
                        {
                            rightViewController.CreateText("Lobby Leaderboard", new Vector2(BASE.x + 62.5f, BASE.y));
                        }
                        RefreshScores();
                    });
                } catch (Exception e)
                {
                    Logger.Error(e);
                }
            }
        }