Beispiel #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);
        }
Beispiel #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);
            });
        }
Beispiel #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;
            }
        }
Beispiel #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;
        }
Beispiel #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();
     }
 }
Beispiel #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);
                });
            });
        }
Beispiel #7
0
 private void load(SkinEditor editor)
 {
     SelectedItems.BindTo(editor.SelectedComponents);
 }