private void SpawnButtons(Texture2D texGithub, Texture2D texTheWitness)
        {
            btnLinkGithub        = new TouchButton(new Rectangle(), texGithub, null, Color.LightGray);
            btnLinkGithub.Click += () =>
            {
                OpenURL(githubUrl);
                SoundManager.PlayOnce(Sound.ButtonNext);
            };

            btnLinkTheWitness        = new TouchButton(new Rectangle(), texTheWitness, null, Color.LightGray);
            btnLinkTheWitness.Click += () =>
            {
                OpenURL(theWitnessUrl);
                SoundManager.PlayOnce(Sound.ButtonNext);
            };

            btnBack        = new TextButton(new Rectangle(), fntBig, "Back", texPixel);
            btnBack.Click += () =>
            {
                ScreenManager.Instance.GoBack();
                SoundManager.PlayOnce(Sound.MenuEscape);
            };

            UpdateButtonsPositionAndSize();
        }
Example #2
0
        private void SpawnPanelButtons()
        {
            int fileIndex = currentPage * panelsOnPage;

            for (int j = 0; j < pageHeight; j++)
            {
                for (int i = 0; i < pageWidth; i++, fileIndex++)
                {
                    if (fileIndex >= fileNames.Length)
                    {
                        break;
                    }

                    Puzzle panel = FileStorageManager.LoadPanelFromFile(fileNames[fileIndex]);
                    renderer.SetPanel(panel);
                    RenderTarget2D texture = new RenderTarget2D(GraphicsDevice, renderWidth, renderHeight);
                    renderer.RenderPanelToTexture(texture);

                    Point size   = new Point((int)(panelSize.X * 0.9f), (int)(panelSize.Y * 0.9f));
                    Point margin = (panelSize - size).Divide(2);
                    Point pos    = new Point(panelsPosition.X + panelSize.X * i + margin.X, panelsPosition.Y + panelSize.Y * j + margin.Y);

                    TouchButton btnPanel = new TouchButton(new Rectangle(pos, size), texture);
                    btnPanel.Click += () =>
                    {
                        ScreenManager.Instance.AddScreen <PanelGameScreen>(false, true, panel, true);
                        SoundManager.PlayOnce(Sound.MenuEnter);
                    };
                    panels.Add(btnPanel);
                }
            }
        }
Example #3
0
        private void SpawnButtons(Texture2D texLeft, Texture2D texRight)
        {
            btnDown        = new TouchButton(new Rectangle(), texLeft);
            btnDown.Click += () =>
            {
                if (Value > minValue)
                {
                    Value = Math.Max(minValue, Value - step);
                    ValueChanged?.Invoke();
                    SoundManager.PlayOnce(Sound.ButtonNext, 0.8f);
                }
            };

            btnUp        = new TouchButton(new Rectangle(), texRight);
            btnUp.Click += () =>
            {
                if (Value < maxValue)
                {
                    Value = Math.Min(maxValue, Value + step);
                    ValueChanged?.Invoke();
                    SoundManager.PlayOnce(Sound.ButtonNext, 0.8f);
                }
            };

            UpdateButtonsPositionAndSize();
        }
Example #4
0
        private void SpawnButtons()
        {
            // Tabs
            TabButton btnSolved = new TabButton(new Rectangle(), texPixel, texSolved, null, Color.DarkGray, new Color(14, 14, 14));

            btnSolved.Click += () =>
            {
                currentTab  = HistoryTab.Solved;
                currentPage = 0;
                fileNames   = FileStorageManager.GetSolvedPanelsNames();
                UpdatePageSize();
                RespawnPanelButtons();
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };
            tabs.Add(btnSolved);

            TabButton btnDiscarded = new TabButton(new Rectangle(), texPixel, texDiscarded, null, Color.DarkGray, new Color(14, 14, 14));

            btnDiscarded.Click += () =>
            {
                currentTab  = HistoryTab.Discarded;
                currentPage = 0;
                fileNames   = FileStorageManager.GetDiscardedPanelsNames();
                UpdatePageSize();
                RespawnPanelButtons();
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };
            tabs.Add(btnDiscarded);

            TabButton btnFavs = new TabButton(new Rectangle(), texPixel, texFavourite, null, Color.DarkGray, new Color(14, 14, 14));

            btnFavs.Click += () =>
            {
                currentTab  = HistoryTab.Favourites;
                currentPage = 0;
                fileNames   = FileStorageManager.GetFavouritePanelsNames();
                UpdatePageSize();
                RespawnPanelButtons();
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };
            tabs.Add(btnFavs);

            // Other buttons
            foreach (TabButton tab in tabs)
            {
                foreach (TabButton otherTab in tabs.Where(x => x != tab))
                {
                    tab.ConnectTab(otherTab);
                }
            }
            btnSolved.Activate();

            btnBack        = new TextButton(new Rectangle(), font, "Back", texPixel);
            btnBack.Click += () =>
            {
                ScreenManager.Instance.GoBack();
                SoundManager.PlayOnce(Sound.MenuEscape);
            };

            btnPrevPage        = new TouchButton(new Rectangle(), texLeft);
            btnPrevPage.Click += () =>
            {
                if (currentPage > 0)
                {
                    currentPage--;
                    RespawnPanelButtons();
                }
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };

            btnNextPage        = new TouchButton(new Rectangle(), texRight);
            btnNextPage.Click += () =>
            {
                if (currentPage < maxPage)
                {
                    currentPage++;
                    RespawnPanelButtons();
                }
                SoundManager.PlayOnce(Sound.ButtonNext, 0.75f);
            };

            UpdateButtonsPositions();
        }
Example #5
0
        private void SpawnButtons()
        {
            TouchButton btnClose = new TouchButton(new Rectangle(), texClose, null);

            btnClose.Click += () => {
                AbortTracing();
                SoundManager.PlayOnce(Sound.MenuOpen);
                ScreenManager.Instance.GoBack();
            };
            buttons.Add(btnClose);

            ToggleButton btnLike = new ToggleButton(new Rectangle(), texLike[1], texLike[0], null, FileStorageManager.IsPanelInFavourites(panel));

            btnLike.Click += () =>
            {
                // Add panel the list of favourite panels (or remove from it)
                if (btnLike.IsActivated)
                {
                    FileStorageManager.AddPanelToFavourites(panel);
                }
                else
                {
                    FileStorageManager.DeletePanelFromFavourites(panel);
                }

                SoundManager.PlayOnce(btnLike.IsActivated ? Sound.ButtonLike : Sound.ButtonUnlike);
            };
            buttons.Add(btnLike);

            // When panel is standalone, it cannot have Next button
            if (!IsStandalonePanel)
            {
                TwoStateButton btnNext = new TwoStateButton(new Rectangle(), texDelete, texNext, null, null, null, false);
                btnNext.Click += () =>
                {
                    Action callback = null;
                    callback = () =>
                    {
                        AbortTracing();
                        Puzzle nextPanel = DI.Get <PanelGenerator>().GeneratePanel();
                        FileStorageManager.SaveCurrentPanel(nextPanel);
                        LoadNewPanel(nextPanel);
                        btnNext.StateActive = false;
                        btnLike.Deactivate();
                        fade.FadeOutComplete -= callback;
                    };

                    // Add panel to the list of last 10 discarded panels
                    if (!btnNext.StateActive)
                    {
                        FileStorageManager.AddPanelToDiscardedList(panel);
                    }

                    SoundManager.PlayOnce(btnNext.StateActive ? Sound.ButtonNextSuccess : Sound.ButtonNext);
                    fade.FadeOutComplete += callback;
                    fade.Restart();
                };
                buttons.Add(btnNext);
            }

            UpdateButtonsPosition();
        }