示例#1
0
 protected override void SubmitUI()
 {
     // Основное окно
     ImGui.SetNextWindowPos(new Vector2(0, 0));
     ImGui.SetNextWindowSize(new Vector2(_window.Width, _window.Height));
     ImGui.Begin("ImGui Window", ref _mainWindow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoBringToFrontOnFocus);
     if (ImGui.Button("Colors"))
     {
         _configWindow = true;
     }
     ImGui.SameLine();
     if (ImGui.Button("Generate"))
     {
         GenerateButtonPressed?.Invoke();
     }
     ImGui.SameLine();
     ImGui.Text(_loadingText);
     ImGui.Image(_image, new Vector2(640, 480));
     ImGui.End();
     if (_configWindow)
     {
         ConfigColor();
     }
 }
示例#2
0
        protected override void DidActivate(bool firstActivation, ActivationType activationType)
        {
            base.DidActivate(firstActivation, activationType);
            if (firstActivation && activationType == ActivationType.AddedToHierarchy)
            {
                //Difficulty selection toggle
                AddMultiSelectOption("Preferred Difficulty", new Dictionary <float, string>
                {
                    { 0, "Easy" },
                    { 1, "Normal" },
                    { 2, "Hard" },
                    { 3, "Expert" },
                    { 4, "Expert+" }
                }, rectTransform, gameObject, (v) =>
                {
                    PreferredDifficulty = (BeatmapDifficulty)(int)v;
                    Logger.Debug($"Preferred difficulty: {PreferredDifficulty}");
                }, new Vector2(33, -4));

                AddMultiSelectOption("Play <i>only</i> Preferred Difficulty", new Dictionary <float, string>
                {
                    { 0, "No" },
                    { 1, "Yes" }
                }, rectTransform, gameObject, (v) =>
                {
                    UseOnlyPreferredDifficulty = v == 1;
                    Logger.Debug($"Use only preferred difficulty: {UseOnlyPreferredDifficulty}");
                }, new Vector2(33, -18));

                //Help text
                var helpText = BeatSaberUI.CreateText(rectTransform, $"Welcome to {Plugin.Name}!\nRemember: <color=\"green\">You can also enable {Plugin.Name} as a Game Option on the left hand panel when you're in the song menu.</color>", new Vector2(0, 20f));
                helpText.enableWordWrapping = true;
                helpText.alignment          = TextAlignmentOptions.Center;

                var disclaimer = BeatSaberUI.CreateText(rectTransform, $"<color=\"red\">Play responsibly! Remember to stay hydrated and always pause to take a break if you feel tired.</color>", new Vector2(-46f, -8f));
                disclaimer.rectTransform.sizeDelta -= new Vector2(20f, 0);
                disclaimer.enableWordWrapping       = true;
                disclaimer.alignment = TextAlignmentOptions.Center;

                var timeLabelText = BeatSaberUI.CreateText(rectTransform, "Minimum time for generated playlist:", new Vector2(0, 5));
                timeLabelText.enableWordWrapping = true;
                timeLabelText.alignment          = TextAlignmentOptions.Center;

                //Display position presets
                var displayPositionX = 0f;
                var displayPositionY = -13f;

                //Time selection text
                timeText = BeatSaberUI.CreateText(rectTransform, "0  :  0   0", new Vector2(displayPositionX - 2f, displayPositionY + 3));
                timeText.autoSizeTextContainer = true;
                timeText.fontSize = 12f;

                //Time selection buttons
                AddArrowButton(rectTransform, () => {
                    if (hours < 9)
                    {
                        hours++;
                    }
                    UpdateTimeText();

                    Logger.Debug($"{t.sizeDelta.x} {t.sizeDelta.y}");
                }, new Vector2(displayPositionX - 15, displayPositionY + 8));

                AddArrowButton(rectTransform, () => {
                    if (tenMinutes < 5)
                    {
                        tenMinutes++;
                    }
                    UpdateTimeText();
                }, new Vector2(displayPositionX, displayPositionY + 8));

                AddArrowButton(rectTransform, () => {
                    if (minutes < 9)
                    {
                        minutes++;
                    }
                    UpdateTimeText();
                }, new Vector2(displayPositionX + 10.7f, displayPositionY + 8));

                AddArrowButton(rectTransform, () => {
                    if (hours > 0)
                    {
                        hours--;
                    }
                    UpdateTimeText();
                }, new Vector2(displayPositionX - 15, displayPositionY - 8), true);

                AddArrowButton(rectTransform, () => {
                    if (tenMinutes > 0)
                    {
                        tenMinutes--;
                    }
                    UpdateTimeText();
                }, new Vector2(displayPositionX, displayPositionY - 8), true);

                AddArrowButton(rectTransform, () => {
                    if (minutes > 0)
                    {
                        minutes--;
                    }
                    UpdateTimeText();
                }, new Vector2(displayPositionX + 10.7f, displayPositionY - 8), true);

                //Playlist generate button
                generateButton = BeatSaberUI.CreateUIButton(rectTransform, "CreditsButton", new Vector2(0, -28), new Vector2(50, 10), () => GenerateButtonPressed?.Invoke(), "Generate random playlist");

                //Progress bar
                progressBarBackground = new GameObject().AddComponent <Image>();
                var progressBackgroundTransform = progressBarBackground.transform as RectTransform;
                progressBackgroundTransform.SetParent(rectTransform, false);
                progressBackgroundTransform.sizeDelta        = new Vector2(100, 10);
                progressBackgroundTransform.anchoredPosition = new Vector2(0, -28);
                progressBarBackground.color    = new Color(0f, 0f, 0f, 0.2f);
                progressBarBackground.material = Resources.FindObjectsOfTypeAll <Material>().FirstOrDefault(x => x.name == "UINoGlow");
                progressBarBackground.gameObject.SetActive(false);

                progressBar = new GameObject().AddComponent <Image>();
                var progressBarTransform = progressBar.transform as RectTransform;
                progressBarTransform.SetParent(rectTransform, false);
                progressBarTransform.sizeDelta        = new Vector2(100, 10);
                progressBarTransform.anchoredPosition = new Vector2(0, -28);
                progressBar.color    = Color.white;
                progressBar.material = Resources.FindObjectsOfTypeAll <Material>().FirstOrDefault(x => x.name == "UINoGlow");
                var whiteTexture = Texture2D.whiteTexture;
                var sprite       = Sprite.Create(whiteTexture, new Rect(0f, 0f, whiteTexture.width, whiteTexture.height), Vector2.one * 0.5f, 100f, 1u);
                progressBar.sprite     = sprite;
                progressBar.type       = Image.Type.Filled;
                progressBar.fillMethod = Image.FillMethod.Horizontal;
                progressBar.gameObject.SetActive(false);
            }
        }