Skip to content
Snippets Groups Projects
Commit f2dbba1e authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

#178 - Merge trigger point "end" with "end of file", fix trigger firing

parent 5a2bb150
No related branches found
No related tags found
No related merge requests found
...@@ -214,7 +214,6 @@ Trigger.Volume.Name=Lautst\u00E4rke ...@@ -214,7 +214,6 @@ Trigger.Volume.Name=Lautst\u00E4rke
TriggerPoint.START=Start TriggerPoint.START=Start
TriggerPoint.STOP=Stop TriggerPoint.STOP=Stop
TriggerPoint.EOF=Ende TriggerPoint.EOF=Ende
TriggerPoint.EOF_STATE=Ende (EoF)
# Drag and Drop Mode # Drag and Drop Mode
DnDMode.Replace=Ersetzen DnDMode.Replace=Ersetzen
......
...@@ -21,17 +21,17 @@ public class PadTriggerStatusListener implements ChangeListener<PadStatus> { ...@@ -21,17 +21,17 @@ public class PadTriggerStatusListener implements ChangeListener<PadStatus> {
} }
@Override @Override
public void changed(ObservableValue<? extends PadStatus> observable, PadStatus oldValue, PadStatus newValue) { public void changed(ObservableValue<? extends PadStatus> observable, PadStatus oldState, PadStatus newValue) {
if (!pad.isIgnoreTrigger()) { if (!pad.isIgnoreTrigger()) {
PadSettings padSettings = pad.getPadSettings(); PadSettings padSettings = pad.getPadSettings();
// Execute Trigger // Execute Trigger
if (newValue == PadStatus.PLAY) { if (newValue == PadStatus.PLAY) {
executeTrigger(padSettings.getTriggers().get(TriggerPoint.START)); executeTrigger(padSettings.getTriggers().get(TriggerPoint.START));
} else if (newValue == PadStatus.STOP) { } else if (newValue == PadStatus.STOP && !pad.isEof()) {
executeTrigger(padSettings.getTriggers().get(TriggerPoint.STOP)); executeTrigger(padSettings.getTriggers().get(TriggerPoint.STOP));
} else if (oldValue == PadStatus.PLAY && newValue == PadStatus.READY && pad.isEof()) { } else if (oldState == PadStatus.STOP && newValue == PadStatus.READY && pad.isEof()){
executeTrigger(padSettings.getTriggers().get(TriggerPoint.EOF_STATE)); executeTrigger(padSettings.getTriggers().get(TriggerPoint.EOF));
} }
} else { } else {
pad.setIgnoreTrigger(false); pad.setIgnoreTrigger(false);
......
...@@ -109,23 +109,15 @@ public class Trigger { ...@@ -109,23 +109,15 @@ public class Trigger {
if (triggerPoint == TriggerPoint.START) { if (triggerPoint == TriggerPoint.START) {
handleStartPoint(pad, currentDuration, project, mainViewController, currentProfile, item); handleStartPoint(pad, currentDuration, project, mainViewController, currentProfile, item);
} else if (triggerPoint == TriggerPoint.STOP) { } else if (triggerPoint == TriggerPoint.STOP) {
handleEndPoint(pad, currentDuration, project, mainViewController, currentProfile, item); item.performAction(pad, project, mainViewController, currentProfile);
} else if (triggerPoint == TriggerPoint.EOF) { } else if (triggerPoint == TriggerPoint.EOF) {
handleEndPoint(pad, currentDuration, project, mainViewController, currentProfile, item); if (item.getDurationFromPoint() == Duration.ZERO && pad.isEof()) {
} else if (triggerPoint == TriggerPoint.EOF_STATE) {
item.performAction(pad, project, mainViewController, currentProfile); item.performAction(pad, project, mainViewController, currentProfile);
} else {
handleEndPoint(pad, currentDuration, project, mainViewController, currentProfile, item);
} }
} }
} }
private void handleEndPoint(Pad pad, Duration duration, Project project, IMainViewController mainViewController, Profile currentProfile, TriggerItem item) {
// Wenn Trigger noch nicht gespielt wurde (null) und Zeit größer ist als gesetzte Zeit (oder 0)
if (item.getPerformedAt() == null && (item.getDurationFromPoint().greaterThan(duration) || duration.equals(Duration.ZERO))) {
item.performAction(pad, project, mainViewController, currentProfile);
item.setPerformedAt(duration);
} else if (item.getDurationFromPoint().lessThan(duration)) {
item.setPerformedAt(null);
}
} }
private void handleStartPoint(Pad pad, Duration duration, Project project, IMainViewController mainViewController, Profile currentProfile, TriggerItem item) { private void handleStartPoint(Pad pad, Duration duration, Project project, IMainViewController mainViewController, Profile currentProfile, TriggerItem item) {
...@@ -142,4 +134,14 @@ public class Trigger { ...@@ -142,4 +134,14 @@ public class Trigger {
} }
} }
} }
private void handleEndPoint(Pad pad, Duration duration, Project project, IMainViewController mainViewController, Profile currentProfile, TriggerItem item) {
// Wenn Trigger noch nicht gespielt wurde (null) und Zeit größer ist als gesetzte Zeit (oder 0)
if (item.getPerformedAt() == null && (item.getDurationFromPoint().greaterThan(duration) || duration.equals(Duration.ZERO))) {
item.performAction(pad, project, mainViewController, currentProfile);
item.setPerformedAt(duration);
} else if (item.getDurationFromPoint().lessThan(duration)) {
item.setPerformedAt(null);
}
}
} }
...@@ -4,8 +4,7 @@ public enum TriggerPoint { ...@@ -4,8 +4,7 @@ public enum TriggerPoint {
START(true), START(true),
STOP(false), STOP(false),
EOF(true), EOF(true);
EOF_STATE(false);
/** /**
* Defines if a trigger can be run after, before a certain event. * Defines if a trigger can be run after, before a certain event.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment