Exemple #1
0
 private void Initialize()
 {
     initializeFinished = false;
     currentModInfo     = ModManager.Instance.Root;
     Reload();
     waitSprite.Hidden = true;
     initialized       = true;
 }
Exemple #2
0
        void ModPanel_Inputed(IFocusable sender, InputEventArgs args)
        {
            if (!initialized || updating)
            {
                return;
            }

            if (args.InputInfo.IsPressed(ButtonType.Cross))
            {
                if (currentModInfo == ModManager.Instance.Root)
                {
                    FocusManager.RemoveFocus();
                }
                else
                {
                    var selectIndex = Array.IndexOf(currentModInfo.Parent.Children, currentModInfo);
                    currentModInfo = currentModInfo.Parent;
                    Reload(selectIndex);
                }
                sound.Play(PPDSetting.DefaultSounds[2], -1000);
            }
            else if (args.InputInfo.IsPressed(ButtonType.Circle))
            {
                if (currentIndex >= 0)
                {
                    if (CurrentComponent.ModInfoBase.IsDir)
                    {
                        currentModInfo = CurrentComponent.ModInfoBase;
                        Reload(0);
                        sound.Play(PPDSetting.DefaultSounds[1], -1000);
                    }
                    else
                    {
                        var modComponent = (ModInfoComponent)CurrentComponent;
                        if (modComponent.CanApply)
                        {
                            modComponent.ModInfo.IsApplied = !modComponent.ModInfo.IsApplied;
                            sound.Play(PPDSetting.DefaultSounds[3], -1000);
                        }
                    }
                }
            }
            else if (args.InputInfo.IsPressed(ButtonType.Triangle))
            {
                if (currentIndex >= 0 && !CurrentComponent.ModInfoBase.IsDir)
                {
                    var modComponent = (ModInfoComponent)CurrentComponent;
                    if (modComponent.ModInfo.Settings.Length > 0)
                    {
                        var modSettingPanel = new ModSettingPanel(device, gameHost, resourceManager, sound, modComponent.ModInfo);
                        modSettingPanel.LostFocused += (s, e) =>
                        {
                            this.RemoveChild(modSettingPanel);
                        };
                        FocusManager.Focus(modSettingPanel);
                        sound.Play(PPDSetting.DefaultSounds[1], -1000);
                        this.InsertChild(modSettingPanel, 0);
                    }
                }
            }
            else if (args.InputInfo.IsPressed(ButtonType.Square))
            {
                if (currentIndex >= 0 && !CurrentComponent.ModInfoBase.IsDir)
                {
                    var modComponent = (ModInfoComponent)CurrentComponent;
                    if (modComponent.ModInfo.CanUpdate)
                    {
                        updating            = true;
                        updateSprite.Hidden = false;
                        modComponent.ModInfo.UpdateFinished += ModInfo_UpdateFinished;
                        ThreadManager.Instance.GetThread(() => modComponent.ModInfo.Update()).Start();
                    }
                }
            }
            else if (args.InputInfo.IsPressed(ButtonType.Down))
            {
                if (currentIndex >= 0)
                {
                    CurrentComponent.Selected = false;
                    currentIndex++;
                    if (currentIndex >= currentModInfo.Children.Length)
                    {
                        currentIndex = 0;
                    }
                    CurrentComponent.Selected = true;
                    sound.Play(PPDSetting.DefaultSounds[0], -1000);
                    AdjustScrollBar();
                    ChangeModInfo();
                }
            }
            else if (args.InputInfo.IsPressed(ButtonType.Up))
            {
                if (currentIndex >= 0)
                {
                    CurrentComponent.Selected = false;
                    currentIndex--;
                    if (currentIndex < 0)
                    {
                        currentIndex = currentModInfo.Children.Length - 1;
                    }
                    CurrentComponent.Selected = true;
                    sound.Play(PPDSetting.DefaultSounds[0], -1000);
                    AdjustScrollBar();
                    ChangeModInfo();
                }
            }
        }