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

#187 - Add option to trigger cart by index

parent 1cf0f0af
No related branches found
No related tags found
No related merge requests found
...@@ -2,8 +2,10 @@ package de.tobias.playpad.plugin.api.websocket.methods ...@@ -2,8 +2,10 @@ package de.tobias.playpad.plugin.api.websocket.methods
import com.google.gson.JsonObject import com.google.gson.JsonObject
import de.tobias.playpad.PlayPadPlugin import de.tobias.playpad.PlayPadPlugin
import de.tobias.playpad.pad.PadStatus
import de.tobias.playpad.plugin.api.websocket.MethodExecutable import de.tobias.playpad.plugin.api.websocket.MethodExecutable
import de.tobias.playpad.plugin.api.websocket.message.Message import de.tobias.playpad.plugin.api.websocket.message.Message
import de.tobias.playpad.project.page.PadIndex
import javafx.application.Platform import javafx.application.Platform
import org.eclipse.jetty.websocket.api.Session import org.eclipse.jetty.websocket.api.Session
...@@ -12,11 +14,23 @@ import java.util.UUID ...@@ -12,11 +14,23 @@ import java.util.UUID
class CartActionMethod extends MethodExecutable { class CartActionMethod extends MethodExecutable {
override def execute(session: Session, message: Message): JsonObject = { override def execute(session: Session, message: Message): JsonObject = {
val padId = UUID.fromString(message.payload.get("pad").getAsString) val padId = if (message.payload.get("padId") != null) {
UUID.fromString(message.payload.get("padId").getAsString)
} else if (message.payload.get("padIndex") != null) {
val padIndex = message.payload.get("padIndex").getAsInt
val currentPage = PlayPadPlugin.getInstance().getMainViewController.getPage
val pad = PlayPadPlugin.getInstance().getCurrentProject.getPad(new PadIndex(padIndex, currentPage))
pad.getUuid
} else {
throw new IllegalArgumentException("Neither pad nor padIndex provided")
}
val currentProject = PlayPadPlugin.getInstance().getCurrentProject val currentProject = PlayPadPlugin.getInstance().getCurrentProject
val pad = currentProject.getPad(padId) val pad = currentProject.getPad(padId)
if (pad == null || pad.getStatus == PadStatus.EMPTY || pad.getStatus == PadStatus.ERROR) {
return null
}
Platform.runLater(() => { Platform.runLater(() => {
if (pad.isPlay) { if (pad.isPlay) {
pad.stop() pad.stop()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment