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); }
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); }); }
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; } }
/// <summary> /// Exit any existing skin editor due to the game state changing. /// </summary> public void Reset() { skinEditor?.Save(); skinEditor?.Hide(); skinEditor?.Expire(); skinEditor = null; }
public override void Show() { // base call intentionally omitted. if (skinEditor == null) { LoadComponentAsync(skinEditor = new SkinEditor(target), AddInternal); skinEditor.State.BindValueChanged(editorVisibilityChanged); } else { skinEditor.Show(); } }
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); }); }); }
private void load(SkinEditor editor) { SelectedItems.BindTo(editor.SelectedComponents); }