Esempio n. 1
0
        public bool OnPressed(GlobalAction action)
        {
            switch (action)
            {
            case GlobalAction.Back:
                if (skinEditor?.State.Value == Visibility.Visible)
                {
                    skinEditor.ToggleVisibility();
                    return(true);
                }

                break;

            case GlobalAction.ToggleSkinEditor:
                if (skinEditor == null)
                {
                    LoadComponentAsync(skinEditor = new SkinEditor(target), AddInternal);
                    skinEditor.State.BindValueChanged(editorVisibilityChanged);
                }
                else
                {
                    skinEditor.ToggleVisibility();
                }

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        protected override void PopIn()
        {
            if (skinEditor != null)
            {
                skinEditor.Show();
                return;
            }

            var editor = new SkinEditor();

            editor.State.BindValueChanged(visibility => updateComponentVisibility());

            skinEditor = editor;

            LoadComponentAsync(editor, _ =>
            {
                if (editor != skinEditor)
                {
                    return;
                }

                AddInternal(editor);

                SetTarget(lastTargetScreen);
            });
        }
Esempio n. 3
0
        private void setTarget(OsuScreen target)
        {
            if (target == null)
            {
                return;
            }

            Debug.Assert(skinEditor != null);

            if (!target.IsLoaded)
            {
                Scheduler.AddOnce(setTarget, target);
                return;
            }

            if (skinEditor.State.Value == Visibility.Visible)
            {
                skinEditor.UpdateTargetScreen(target);
            }
            else
            {
                skinEditor.Hide();
                skinEditor.Expire();
                skinEditor = null;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Exit any existing skin editor due to the game state changing.
        /// </summary>
        public void Reset()
        {
            skinEditor?.Save();
            skinEditor?.Hide();
            skinEditor?.Expire();

            skinEditor = null;
        }
Esempio n. 5
0
 public override void Show()
 {
     // base call intentionally omitted.
     if (skinEditor == null)
     {
         LoadComponentAsync(skinEditor = new SkinEditor(target), AddInternal);
         skinEditor.State.BindValueChanged(editorVisibilityChanged);
     }
     else
     {
         skinEditor.Show();
     }
 }
Esempio n. 6
0
        public override void Show()
        {
            // base call intentionally omitted as we have custom behaviour.

            if (skinEditor != null)
            {
                skinEditor.Show();
                return;
            }

            var editor = new SkinEditor(target);

            editor.State.BindValueChanged(editorVisibilityChanged);

            skinEditor = editor;

            // Schedule ensures that if `Show` is called before this overlay is loaded,
            // it will not throw (LoadComponentAsync requires the load target to be in a loaded state).
            Schedule(() =>
            {
                if (editor != skinEditor)
                {
                    return;
                }

                LoadComponentAsync(editor, _ =>
                {
                    if (editor != skinEditor)
                    {
                        return;
                    }

                    AddInternal(editor);
                });
            });
        }
Esempio n. 7
0
 private void load(SkinEditor editor)
 {
     SelectedItems.BindTo(editor.SelectedComponents);
 }