X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2FLogicUIStandalone.java;h=2febb5cbd51c6e6c9a1af410817b947ef88e2aa2;hb=0ce7f7122a702c3d6a4b864172b8c93620c8b03b;hp=fea7e184078a00fc3114f8c0af830e2992419f12;hpb=da0a4b7d0619283bb4384091356ce3f105c84e78;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/LogicUIStandalone.java b/LogicUI/src/era/mi/gui/LogicUIStandalone.java index fea7e184..2febb5cb 100644 --- a/LogicUI/src/era/mi/gui/LogicUIStandalone.java +++ b/LogicUI/src/era/mi/gui/LogicUIStandalone.java @@ -7,7 +7,7 @@ import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; -import era.mi.logic.Simulation; +import era.mi.logic.timeline.Timeline; import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay; import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput; @@ -21,9 +21,11 @@ public class LogicUIStandalone private final Display display; private final Shell shell; private final LogicUICanvas ui; + private Timeline timeline; - public LogicUIStandalone() + public LogicUIStandalone(Timeline timeline) { + this.timeline = timeline; display = new Display(); shell = new Shell(display); shell.setLayout(new FillLayout()); @@ -52,10 +54,10 @@ public class LogicUIStandalone while (running.get()) { // always execute to keep timeline from "hanging behind" for too long - Simulation.TIMELINE.executeUpTo(System.currentTimeMillis(), System.currentTimeMillis() + 10); + timeline.executeUntil(timeline.laterThan(System.currentTimeMillis()), System.currentTimeMillis() + 10); long sleepTime; - if (Simulation.TIMELINE.hasNext()) - sleepTime = Simulation.TIMELINE.nextEventTime() - System.currentTimeMillis(); + if (timeline.hasNext()) + sleepTime = timeline.nextEventTime() - System.currentTimeMillis(); else sleepTime = 10; try @@ -69,7 +71,7 @@ public class LogicUIStandalone } }); simulationThread.start(); - Simulation.TIMELINE.addEventAddedListener(event -> + timeline.addEventAddedListener(event -> { if (event.getTiming() <= System.currentTimeMillis()) simulationThread.interrupt();