public void NodeEditor_EndEdit(string nodeText)
    {
        CMInputCallbackInstaller.ClearDisabledActionMaps(new[] { typeof(CMInput.INodeEditorActions) });
        try
        {
            if (!isEditing || !IsActive || SelectionController.SelectedObjects.Count != 1)
            {
                return;
            }
            JSONNode newNode = JSON.Parse(nodeText);      //Parse JSON, and do some basic checks.
            if (string.IsNullOrEmpty(newNode.ToString())) //Damn you Jackz
            {
                throw new Exception("Invalid JSON!\n\nCheck to make sure the node is not empty.");
            }
            if (string.IsNullOrEmpty(newNode["_time"]))
            {
                throw new Exception("Invalid JSON!\n\nEvery object needs a \"_time\" value!");
            }

            //From this point on, its the mappers fault for whatever shit happens from JSON.

            BeatmapObject original = BeatmapObject.GenerateCopy(editingContainer.objectData);
            editingContainer.objectData = Activator.CreateInstance(editingContainer.objectData.GetType(), new object[] { newNode }) as BeatmapObject;
            BeatmapActionContainer.AddAction(new NodeEditorUpdatedNodeAction(editingContainer, editingContainer.objectData, original));
            UpdateAppearance(editingContainer);
            isEditing = false;
        }
        catch (Exception e) { PersistentUI.Instance.ShowDialogBox(e.Message, null, PersistentUI.DialogBoxPresetType.Ok); }
    }
Example #2
0
    private IEnumerator CloseOptions()
    {
        yield return(StartCoroutine(Close(2, optionsCanvasGroup)));

        CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(OptionsController), typeof(CMInput).GetNestedTypes().Where(x => x.IsInterface));
        IsActive = false;
        yield return(SceneManager.UnloadSceneAsync(SceneManager.GetSceneByName("04_Options")));
    }
Example #3
0
    public void SendResult(int buttonID)
    {
        CMInputCallbackInstaller.ClearDisabledActionMaps(disabledActionMaps);
        UpdateGroup(false);
        string res = (string.IsNullOrEmpty(InputField.text) || string.IsNullOrWhiteSpace(InputField.text)) ? "" : InputField.text;

        resultAction?.Invoke(buttonID == 0 ? res : null);
    }
Example #4
0
    public void SendResult(int buttonID)
    {
        CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(CM_InputBox), disabledActionMaps);
        UpdateGroup(false);
        string res = string.IsNullOrWhiteSpace(InputField.text) ? "" : InputField.text;

        resultAction?.Invoke(buttonID == 0 ? res : null);
        resultAction = null;
    }
    public void NodeEditor_EndEdit(string nodeText)
    {
        CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(NodeEditorController), new[] { typeof(CMInput.INodeEditorActions) });
        CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(NodeEditorController), actionMapsDisabled);

        try
        {
            if (!isEditing || !IsActive)
            {
                return;
            }
            JSONNode newNode = JSON.Parse(nodeText);      //Parse JSON, and do some basic checks.
            if (string.IsNullOrEmpty(newNode.ToString())) //Damn you Jackz
            {
                throw new Exception("Node cannot be empty.");
            }

            // Super sneaky clone, maybe not needed
            var dict = editingObjects.ToDictionary(it => it, it => it.ConvertToJSON().Clone());

            ApplyJSON(editingNode.AsObject, newNode.AsObject, dict);

            var beatmapActions = dict.Select(entry =>
                                             new BeatmapObjectModifiedAction(
                                                 Activator.CreateInstance(entry.Key.GetType(), new object[] { entry.Value }) as BeatmapObject,
                                                 entry.Key, entry.Key, $"Edited a {entry.Key.beatmapType} with Node Editor.", true)
                                             ).ToList();

            BeatmapActionContainer.AddAction(new ActionCollectionAction(beatmapActions, true, true, $"Edited ({editingObjects.Count()}) objects with Node Editor."), true);
            UpdateJSON();
        }
        catch (Exception e)
        {
            string message = e.Message;
            switch (e)
            {
            case JSONParseException jsonParse:     // Error parsing input JSON; tell them what's wrong!
                message = jsonParse.ToUIFriendlyString();
                break;

            case TargetInvocationException invocationException:     // Error when converting JSON to an object; tell them what's wrong!
                message = invocationException.InnerException.Message;
                break;

            default:
                //Log the full error to the console
                Debug.LogError(e);
                break;
            }
            PersistentUI.Instance.ShowDialogBox(message, null, PersistentUI.DialogBoxPresetType.Ok);
        }
    }
 public void OnToggleNodeEditor(InputAction.CallbackContext context)
 {
     if (Settings.Instance.NodeEditor_UseKeybind && AdvancedSetting && context.performed && !PersistentUI.Instance.InputBox_IsEnabled)
     {
         StopAllCoroutines();
         if (IsActive)
         {
             CMInputCallbackInstaller.ClearDisabledActionMaps(new[] { typeof(CMInput.INodeEditorActions) });
             CMInputCallbackInstaller.ClearDisabledActionMaps(actionMapsDisabled);
         }
         else
         {
             CMInputCallbackInstaller.DisableActionMaps(actionMapsDisabled);
         }
         StartCoroutine(UpdateGroup(!IsActive, transform as RectTransform));
     }
 }
 private void AttemptPlaceBPMChange(string obj)
 {
     if (string.IsNullOrEmpty(obj) || string.IsNullOrWhiteSpace(obj))
     {
         CMInputCallbackInstaller.ClearDisabledActionMaps(actionMapsDisabled);
         return;
     }
     if (float.TryParse(obj, out float bpm))
     {
         CMInputCallbackInstaller.ClearDisabledActionMaps(actionMapsDisabled);
         queuedData._time = RoundedTime;
         queuedData._BPM  = bpm;
         base.ApplyToMap();
     }
     else
     {
         PersistentUI.Instance.ShowInputBox("Invalid number.\n\nPlease enter the BPM for this new BPM change.",
                                            AttemptPlaceBPMChange, BeatSaberSongContainer.Instance.song.beatsPerMinute.ToString());
     }
 }
Example #8
0
 public void TogglePause()
 {
     IsPaused = !IsPaused;
     if (IsPaused)
     {
         CMInputCallbackInstaller.DisableActionMaps(typeof(PauseManager), disabledActionMaps);
         previousUIModeType = uiMode.selectedMode;
         uiMode.SetUIMode(UIModeType.NORMAL, false);
         foreach (LightsManager e in platform.gameObject.GetComponentsInChildren <LightsManager>())
         {
             e.ChangeAlpha(0, 1, e.ControllingLights);
         }
     }
     else
     {
         CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(PauseManager), disabledActionMaps);
         uiMode.SetUIMode(previousUIModeType, false);
     }
     StartCoroutine(TransitionMenu());
 }
 private void AttemptPlaceBPMChange(string obj)
 {
     if (string.IsNullOrEmpty(obj) || string.IsNullOrWhiteSpace(obj))
     {
         CMInputCallbackInstaller.ClearDisabledActionMaps(actionMapsDisabled);
         containerToEdit = null;
         return;
     }
     if (float.TryParse(obj, out float bpm))
     {
         CMInputCallbackInstaller.ClearDisabledActionMaps(actionMapsDisabled);
         containerToEdit.bpmData._BPM = bpm;
         containerToEdit.UpdateGridPosition();
         containerToEdit = null;
     }
     else
     {
         PersistentUI.Instance.ShowInputBox("Invalid number.\n\nPlease enter the new BPM for this BPM change.",
                                            AttemptPlaceBPMChange, containerToEdit.bpmData._BPM.ToString());
     }
 }
 public void OnToggleNodeEditor(InputAction.CallbackContext context)
 {
     if (nodeEditorInputField.isFocused)
     {
         return;
     }
     if (Settings.Instance.NodeEditor_UseKeybind && context.performed && !PersistentUI.Instance.InputBox_IsEnabled)
     {
         StopAllCoroutines();
         if (IsActive)
         {
             CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(NodeEditorController), new[] { typeof(CMInput.INodeEditorActions) });
             CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(NodeEditorController), actionMapsDisabled);
             BeatmapActionContainer.RemoveAllActionsOfType <NodeEditorTextChangedAction>();
         }
         else
         {
             closeButton.gameObject.SetActive(true);
             CMInputCallbackInstaller.DisableActionMaps(typeof(NodeEditorController), actionMapsDisabled);
         }
         StartCoroutine(UpdateGroup(!IsActive, transform as RectTransform));
     }
 }
Example #11
0
 public void SendResult(int buttonID)
 {
     CMInputCallbackInstaller.ClearDisabledActionMaps(disabledActionMaps);
     UpdateGroup(false);
     resultAction?.Invoke(buttonID);
 }
 public void Close()
 {
     CMInputCallbackInstaller.ClearDisabledActionMaps(new[] { typeof(CMInput.INodeEditorActions) });
     CMInputCallbackInstaller.ClearDisabledActionMaps(actionMapsDisabled);
     StartCoroutine(UpdateGroup(false, transform as RectTransform));
 }
    private IEnumerator ClearDisabledActionMaps()
    {
        yield return(new WaitForEndOfFrame());

        CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(InputBoxFileValidator), new[] { typeof(CMInput.IMenusExtendedActions) });
    }
 public void OnDeselect()
 {
     CMInputCallbackInstaller.ClearDisabledActionMaps(GetType(), typeof(CMInput).GetNestedTypes().Where(x => x.IsInterface));
 }
    private IEnumerator ClearDisabledActionMaps()
    {
        yield return(new WaitForEndOfFrame());

        CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(ContributorListItem), new[] { typeof(CMInput.IMenusExtendedActions) });
    }
Example #16
0
 public void OnDeselect(BaseEventData eventData)
 {
     CMInputCallbackInstaller.ClearDisabledActionMaps(typeof(ColorTMPField), typeof(CMInput).GetNestedTypes().Where(x => x.IsInterface));
 }