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

Add new trigger point: 'EOF_STATE'

parent ae268215
No related branches found
No related tags found
No related merge requests found
...@@ -209,10 +209,13 @@ UI.Window.Settings.Updates.CurrentVersion={} (Build {}) ...@@ -209,10 +209,13 @@ UI.Window.Settings.Updates.CurrentVersion={} (Build {})
TriggerPoint.toString={} ({}) TriggerPoint.toString={} ({})
Trigger.Cart.Name=Kacheln Trigger.Cart.Name=Kacheln
Trigger.Volume.Name=Lautst\u00E4rke Trigger.Volume.Name=Lautst\u00E4rke
# TriggerPoint - Enum # TriggerPoint - Enum
TriggerPoint.START=Start TriggerPoint.START=Start
TriggerPoint.STOP=Stop TriggerPoint.STOP=Stop
TriggerPoint.EOF=Ende (EoF) TriggerPoint.EOF=Ende
TriggerPoint.EOF_STATE=Ende (EoF)
# Drag and Drop Mode # Drag and Drop Mode
DnDMode.Replace=Ersetzen DnDMode.Replace=Ersetzen
DnDMode.Duplicate=Duplizieren DnDMode.Duplicate=Duplizieren
......
...@@ -22,22 +22,22 @@ public class PadTriggerDurationListener implements ChangeListener<Duration> { ...@@ -22,22 +22,22 @@ public class PadTriggerDurationListener implements ChangeListener<Duration> {
} }
@Override @Override
public void changed(ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) { public void changed(ObservableValue<? extends Duration> observable, Duration oldValue, Duration currentTime) {
PadContent content = pad.getContent(); PadContent content = pad.getContent();
if (content instanceof Durationable) { if (content instanceof Durationable) {
Duration totalDuration = ((Durationable) content).getDuration(); Duration totalDuration = ((Durationable) content).getDuration();
if (totalDuration != null) { if (totalDuration != null) {
Duration leftTime = totalDuration.subtract(newValue);
IMainViewController mainViewController = PlayPadPlugin.getInstance().getMainViewController(); IMainViewController mainViewController = PlayPadPlugin.getInstance().getMainViewController();
Profile currentProfile = Profile.currentProfile(); Profile currentProfile = Profile.currentProfile();
PadSettings padSettings = pad.getPadSettings(); PadSettings padSettings = pad.getPadSettings();
// Execute Triggers // Execute Start Triggers
Trigger startTrigger = padSettings.getTrigger(TriggerPoint.START); final Trigger startTrigger = padSettings.getTrigger(TriggerPoint.START);
startTrigger.handle(pad, newValue, pad.getProject(), mainViewController, currentProfile); startTrigger.handle(pad, currentTime, pad.getProject(), mainViewController, currentProfile);
Trigger endTrigger = padSettings.getTrigger(TriggerPoint.EOF); // Execute End Trigger
final Duration leftTime = totalDuration.subtract(currentTime);
final Trigger endTrigger = padSettings.getTrigger(TriggerPoint.EOF);
endTrigger.handle(pad, leftTime, pad.getProject(), mainViewController, currentProfile); endTrigger.handle(pad, leftTime, pad.getProject(), mainViewController, currentProfile);
} }
} }
......
...@@ -26,12 +26,12 @@ public class PadTriggerStatusListener implements ChangeListener<PadStatus> { ...@@ -26,12 +26,12 @@ public class PadTriggerStatusListener implements ChangeListener<PadStatus> {
PadSettings padSettings = pad.getPadSettings(); PadSettings padSettings = pad.getPadSettings();
// Execute Trigger // Execute Trigger
if (newValue == PadStatus.PLAY) { // TRIGGER FÜR START if (newValue == PadStatus.PLAY) {
executeTrigger(padSettings.getTriggers().get(TriggerPoint.START)); executeTrigger(padSettings.getTriggers().get(TriggerPoint.START));
} else if (newValue == PadStatus.STOP) { // TRIGGER FÜR STOP } else if (newValue == PadStatus.STOP) {
executeTrigger(padSettings.getTriggers().get(TriggerPoint.STOP)); executeTrigger(padSettings.getTriggers().get(TriggerPoint.STOP));
} else if (oldValue == PadStatus.PLAY && newValue == PadStatus.READY && pad.isEof()) { // TRIGGER FÜR EOF } else if (oldValue == PadStatus.PLAY && newValue == PadStatus.READY && pad.isEof()) {
executeTrigger(padSettings.getTriggers().get(TriggerPoint.EOF)); executeTrigger(padSettings.getTriggers().get(TriggerPoint.EOF_STATE));
} }
} else { } else {
pad.setIgnoreTrigger(false); pad.setIgnoreTrigger(false);
......
...@@ -104,20 +104,22 @@ public class Trigger { ...@@ -104,20 +104,22 @@ public class Trigger {
return triggerPoint.name() + " (" + items.size() + ")"; return triggerPoint.name() + " (" + items.size() + ")";
} }
public void handle(Pad pad, Duration duration, Project project, IMainViewController mainViewController, Profile currentProfile) { public void handle(Pad pad, Duration currentDuration, Project project, IMainViewController mainViewController, Profile currentProfile) {
for (TriggerItem item : items) { for (TriggerItem item : items) {
if (triggerPoint == TriggerPoint.START) { if (triggerPoint == TriggerPoint.START) {
handleStartPoint(pad, duration, project, mainViewController, currentProfile, item); handleStartPoint(pad, currentDuration, project, mainViewController, currentProfile, item);
} else if (triggerPoint == TriggerPoint.STOP) { } else if (triggerPoint == TriggerPoint.STOP) {
handleEndPoint(pad, duration, project, mainViewController, currentProfile, item); handleEndPoint(pad, currentDuration, project, mainViewController, currentProfile, item);
} else if (triggerPoint == TriggerPoint.EOF) { } else if (triggerPoint == TriggerPoint.EOF) {
handleEndPoint(pad, duration, project, mainViewController, currentProfile, item); handleEndPoint(pad, currentDuration, project, mainViewController, currentProfile, item);
} else if (triggerPoint == TriggerPoint.EOF_STATE) {
item.performAction(pad, project, mainViewController, currentProfile);
} }
} }
} }
private void handleEndPoint(Pad pad, Duration duration, Project project, IMainViewController mainViewController, Profile currentProfile, TriggerItem item) { private void handleEndPoint(Pad pad, Duration duration, Project project, IMainViewController mainViewController, Profile currentProfile, TriggerItem item) {
// Wenn Trigger noch nicht gespiel wurde (null) und Zeit größer ist als gesetzte Zeit (oder 0) // 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))) { if (item.getPerformedAt() == null && (item.getDurationFromPoint().greaterThan(duration) || duration.equals(Duration.ZERO))) {
item.performAction(pad, project, mainViewController, currentProfile); item.performAction(pad, project, mainViewController, currentProfile);
item.setPerformedAt(duration); item.setPerformedAt(duration);
...@@ -128,7 +130,7 @@ public class Trigger { ...@@ -128,7 +130,7 @@ public class Trigger {
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) {
if (pad.getStatus() == PadStatus.PLAY) { if (pad.getStatus() == PadStatus.PLAY) {
// Mitten drin, wenn die Zeit die gespiel wurde größer ist als die gesetzte und noch der Trigger noch nicht ausgeführt // Mitten drin, wenn die Zeit die gespielt wurde größer ist als die gesetzte und noch der Trigger noch nicht ausgeführt
// wurde (null) // wurde (null)
if ((item.getPerformedAt() == null && item.getDurationFromPoint().lessThan(duration)) if ((item.getPerformedAt() == null && item.getDurationFromPoint().lessThan(duration))
// Wenn der Trigger am Anfang ist // Wenn der Trigger am Anfang ist
......
...@@ -2,8 +2,21 @@ package de.tobias.playpad.tigger; ...@@ -2,8 +2,21 @@ package de.tobias.playpad.tigger;
public enum TriggerPoint { public enum TriggerPoint {
START, START(true),
STOP, STOP(false),
EOF EOF(true),
EOF_STATE(false);
/**
* Defines if a trigger can be run after, before a certain event.
*/
private final boolean timeAppendable;
TriggerPoint(boolean timeAppendable) {
this.timeAppendable = timeAppendable;
}
public boolean isTimeAppendable() {
return timeAppendable;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment