Exemple #1
0
    //redundant with menuUI but we bear with it
    public new void Update()
    {
        if (!InFocus())
        {
            if (gainFocus)
            {
                Init();
                inFocus = true;
            }
            else
            {
                foreach (SavePanelUI menuElement in savePanels)
                {
                    menuElement.Blur();
                }
            }

            return;
        }

        if (!gainFocus)
        {
            inFocus = false;
            return;
        }

        InputDirection dir = Controls.getInputDirectionDown();

        if (dir == InputDirection.N)
        {
            AudioMaster.instance.PlayMenuSelectSfx();
            selectedSaveIndex--;
            if (selectedSaveIndex < 0)
            {
                selectedSaveIndex = savePanels.Count - 1;
            }
            UpdateOption();
        }
        else if (dir == InputDirection.S)
        {
            AudioMaster.instance.PlayMenuSelectSfx();
            selectedSaveIndex++;
            if (selectedSaveIndex >= savePanels.Count)
            {
                selectedSaveIndex = 0;
            }
            UpdateOption();
        }

        if (Controls.confirmInputDown())
        {
            if (mode == SavePanelMode.Saving && currentSavePoint != null)
            {
                AudioMaster.instance.PlayConfirmSfx();
                ReisenGameManager.instance.SaveGame(savePanels[selectedSaveIndex].fileName, currentSavePoint);
                Init();
            }
            else
            {
                string saveFileName = savePanels[selectedSaveIndex].fileName;
                if (SaveManager.CheckIfSaveDataPresent(saveFileName))
                {
                    AudioMaster.instance.PlayConfirmSfx();

                    if (isTitleScreenVersion)
                    {
                        TitleScreenUtils.instance.LoadGame(saveFileName);
                    }
                    else
                    {
                        ReisenGameManager.instance.LoadGame(saveFileName);
                    }
                    if (!persistOnExit)
                    {
                        this.Close();
                    }
                    else
                    {
                        this.Blur();
                    }
                    this.previousMenu?.Close();
                }
            }
        }
        if (Controls.cancelInputDown())
        {
            AudioMaster.instance.PlayCancelSfx();
            if (!isGameplayMenu)
            {
                if (persistOnExit)
                {
                    this.Blur();
                }
                else
                {
                    this.Close();
                }
                if (prevMenuMode == ParentMenuStatusPostSelect.close)
                {
                    previousMenu?.Open();
                }
                else
                {
                    previousMenu?.Focus();
                }
            }
            else
            {
                this.Close();
                RpgGameManager.instance.ResumeGameplay();
            }
        }
    }