void resetActionRecording() { inputFieldModify = null; lastKnownDirection = ValueDirection.NONE; prevValue = string.Empty; prevSongObject = null; prevSongObjectRef = null; }
void OnDisable() { if (currentEventToCustomise != originalEvent) { ActionHistory.Modify actionHistory = currentChartEvent != null ? new ActionHistory.Modify(originalEvent as ChartEvent, currentChartEvent) : new ActionHistory.Modify(originalEvent as Event, currentEvent); ChartEditor.GetInstance().actionHistory.Insert(actionHistory); } currentEventToCustomise = null; originalEvent = null; eventStr = string.Empty; }
protected void UpdateInputFieldRecord() { if (currentSongObject == null || prevSongObject == null || prevSongObject != currentSongObject) { if (! ( (currentSongObject.GetType() == typeof(ChartEvent) || currentSongObject.GetType() == typeof(Event)) && currentSongObject.GetType() == prevSongObject.GetType() ) ) { return; } } string value = GetValue(currentSongObject); if (value == prevValue || value == GetValue(prevSongObject)) { return; } // Check if there's a record already in if (inputFieldModify == null || lastKnownDirection == ValueDirection.NONE) { // Add a new record inputFieldModify = new ActionHistory.Modify(prevSongObject, currentSongObject); // Add to action history editor.actionHistory.Insert(inputFieldModify); if (GetValue(currentSongObject).Length < GetValue(prevSongObject).Length) { lastKnownDirection = ValueDirection.DOWN; } else if (GetValue(currentSongObject).Length > GetValue(prevSongObject).Length) { lastKnownDirection = ValueDirection.UP; } else { lastKnownDirection = ValueDirection.NONE; } } // Else check if a new record needs to overwrite this current one or if this one needs to be edited else if (inputFieldModify != null) { if (value.Length < prevValue.Length) { if (lastKnownDirection == ValueDirection.DOWN) { // Edit action inputFieldModify.after = currentSongObject.Clone(); } else { // New action inputFieldModify = new ActionHistory.Modify(prevSongObject, currentSongObject); // Add to action history editor.actionHistory.Insert(inputFieldModify); } lastKnownDirection = ValueDirection.DOWN; } else if (value.Length > prevValue.Length) { if (lastKnownDirection == ValueDirection.UP) { // Edit action inputFieldModify.after = currentSongObject.Clone(); } else { // New action inputFieldModify = new ActionHistory.Modify(prevSongObject, currentSongObject); // Add to action history editor.actionHistory.Insert(inputFieldModify); } lastKnownDirection = ValueDirection.UP; } else { // Add a new record inputFieldModify = new ActionHistory.Modify(prevSongObject, currentSongObject); // Add to action history editor.actionHistory.Insert(inputFieldModify); } } prevValue = value; }