mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-27 02:40:51 +01:00
refactor UI, split scheduler
This commit is contained in:
parent
be2c8adecb
commit
cee7fe5160
@ -2,10 +2,6 @@ package extensions.blockreplacepackets;
|
|||||||
|
|
||||||
import extensions.blockreplacepackets.rules.BlockReplaceRule;
|
import extensions.blockreplacepackets.rules.BlockReplaceRule;
|
||||||
import gearth.ui.buttons.DeleteButton;
|
import gearth.ui.buttons.DeleteButton;
|
||||||
import gearth.ui.scheduler.ScheduleItem;
|
|
||||||
import javafx.beans.InvalidationListener;
|
|
||||||
import javafx.beans.Observable;
|
|
||||||
import javafx.event.EventHandler;
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
package gearth.ui.scheduler;
|
package gearth.services.scheduler;
|
||||||
|
|
||||||
|
import gearth.ui.scheduler.SchedulerController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Jonas on 11/04/18.
|
* Created by Jonas on 11/04/18.
|
||||||
@ -21,7 +23,7 @@ public class Interval {
|
|||||||
offset = -1;
|
offset = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Scheduler.stringIsNumber(split[0]) || (split.length == 2 && !Scheduler.stringIsNumber(split[1]))) {
|
if (!SchedulerController.stringIsNumber(split[0]) || (split.length == 2 && !SchedulerController.stringIsNumber(split[1]))) {
|
||||||
delay = -1;
|
delay = -1;
|
||||||
offset = -1;
|
offset = -1;
|
||||||
return;
|
return;
|
@ -1,11 +1,10 @@
|
|||||||
package gearth.ui.scheduler;
|
package gearth.services.scheduler;
|
||||||
|
|
||||||
import gearth.misc.listenerpattern.Observable;
|
import gearth.misc.listenerpattern.Observable;
|
||||||
import gearth.ui.scheduler.listeners.OnBeingUpdatedListener;
|
import gearth.services.scheduler.listeners.OnBeingUpdatedListener;
|
||||||
import gearth.ui.scheduler.listeners.OnDeleteListener;
|
import gearth.services.scheduler.listeners.OnDeleteListener;
|
||||||
import gearth.ui.scheduler.listeners.OnEditListener;
|
import gearth.services.scheduler.listeners.OnEditListener;
|
||||||
import gearth.ui.scheduler.listeners.OnUpdatedListener;
|
import gearth.services.scheduler.listeners.OnUpdatedListener;
|
||||||
import javafx.beans.InvalidationListener;
|
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
import javafx.beans.property.SimpleObjectProperty;
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
@ -13,9 +12,6 @@ import gearth.misc.StringifyAble;
|
|||||||
import gearth.protocol.HMessage;
|
import gearth.protocol.HMessage;
|
||||||
import gearth.protocol.HPacket;
|
import gearth.protocol.HPacket;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Jonas on 07/04/18.
|
* Created by Jonas on 07/04/18.
|
||||||
*/
|
*/
|
||||||
@ -27,7 +23,7 @@ public class ScheduleItem implements StringifyAble {
|
|||||||
private SimpleObjectProperty<HPacket> packetProperty;
|
private SimpleObjectProperty<HPacket> packetProperty;
|
||||||
private SimpleObjectProperty<HMessage.Direction> destinationProperty;
|
private SimpleObjectProperty<HMessage.Direction> destinationProperty;
|
||||||
|
|
||||||
ScheduleItem (int index, boolean paused, Interval delay, HPacket packet, HMessage.Direction destination) {
|
public ScheduleItem (int index, boolean paused, Interval delay, HPacket packet, HMessage.Direction destination) {
|
||||||
construct(index, paused, delay, packet, destination);
|
construct(index, paused, delay, packet, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +35,7 @@ public class ScheduleItem implements StringifyAble {
|
|||||||
this.destinationProperty = new SimpleObjectProperty<>(destination);
|
this.destinationProperty = new SimpleObjectProperty<>(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduleItem(String stringifyAbleRepresentation) {
|
public ScheduleItem(String stringifyAbleRepresentation) {
|
||||||
constructFromString(stringifyAbleRepresentation);
|
constructFromString(stringifyAbleRepresentation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,39 +59,6 @@ public class ScheduleItem implements StringifyAble {
|
|||||||
return destinationProperty;
|
return destinationProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Observable<OnDeleteListener> onDeleteObservable = new Observable<>(OnDeleteListener::onDelete);
|
|
||||||
public void onDelete(OnDeleteListener listener) {
|
|
||||||
onDeleteObservable.addListener(listener);
|
|
||||||
}
|
|
||||||
public void delete() {
|
|
||||||
onDeleteObservable.fireEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<OnEditListener> onEditObservable = new Observable<>(OnEditListener::onEdit);
|
|
||||||
public void onEdit(OnEditListener listener) {
|
|
||||||
onEditObservable.addListener(listener);
|
|
||||||
}
|
|
||||||
public void edit() {
|
|
||||||
onEditObservable.fireEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<OnUpdatedListener> onUpdatedObservable = new Observable<>(OnUpdatedListener::onUpdated);
|
|
||||||
public void onIsupdated(OnUpdatedListener listener) {
|
|
||||||
onUpdatedObservable.addListener(listener);
|
|
||||||
}
|
|
||||||
public void isUpdatedTrigger() {
|
|
||||||
onUpdatedObservable.fireEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<OnBeingUpdatedListener> onBeingUpdatedObservable = new Observable<>(OnBeingUpdatedListener::onBeingUpdated);
|
|
||||||
public void onIsBeingUpdated(OnBeingUpdatedListener listener) {
|
|
||||||
onBeingUpdatedObservable.addListener(listener);
|
|
||||||
}
|
|
||||||
public void onIsBeingUpdatedTrigger() {
|
|
||||||
onBeingUpdatedObservable.fireEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stringify() {
|
public String stringify() {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
@ -0,0 +1,73 @@
|
|||||||
|
package gearth.services.scheduler;
|
||||||
|
|
||||||
|
import gearth.protocol.HConnection;
|
||||||
|
import gearth.protocol.HMessage;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Scheduler<T extends ScheduleItem> {
|
||||||
|
|
||||||
|
private List<T> scheduleItems = new ArrayList<>();
|
||||||
|
|
||||||
|
public Scheduler(HConnection connection) {
|
||||||
|
new Thread(() -> {
|
||||||
|
long t = System.currentTimeMillis();
|
||||||
|
long changed = 1;
|
||||||
|
|
||||||
|
Set<ScheduleItem> set = new HashSet<>();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
set.clear();
|
||||||
|
for (int i = size() - 1; i >= 0; i--) {
|
||||||
|
set.add(get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ScheduleItem item : set) {
|
||||||
|
if (!item.getPausedProperty().get()) {
|
||||||
|
Interval cur = item.getDelayProperty().get();
|
||||||
|
for (int i = 0; i < changed; i++) {
|
||||||
|
if ((t - i) % cur.getDelay() == cur.getOffset()) {
|
||||||
|
if (item.getDestinationProperty().get() == HMessage.Direction.TOSERVER) {
|
||||||
|
connection.sendToServerAsync(item.getPacketProperty().get());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
connection.sendToClientAsync(item.getPacketProperty().get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
long newT = System.currentTimeMillis();
|
||||||
|
changed = newT - t;
|
||||||
|
t = newT;
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return scheduleItems.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get(int i) {
|
||||||
|
return scheduleItems.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(T item) {
|
||||||
|
scheduleItems.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(T item) {
|
||||||
|
scheduleItems.remove(item);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package gearth.ui.scheduler.listeners;
|
package gearth.services.scheduler.listeners;
|
||||||
|
|
||||||
public interface OnBeingUpdatedListener {
|
public interface OnBeingUpdatedListener {
|
||||||
void onBeingUpdated();
|
void onBeingUpdated();
|
@ -1,4 +1,4 @@
|
|||||||
package gearth.ui.scheduler.listeners;
|
package gearth.services.scheduler.listeners;
|
||||||
|
|
||||||
public interface OnDeleteListener {
|
public interface OnDeleteListener {
|
||||||
void onDelete();
|
void onDelete();
|
@ -1,4 +1,4 @@
|
|||||||
package gearth.ui.scheduler.listeners;
|
package gearth.services.scheduler.listeners;
|
||||||
|
|
||||||
public interface OnEditListener {
|
public interface OnEditListener {
|
||||||
void onEdit();
|
void onEdit();
|
@ -1,4 +1,4 @@
|
|||||||
package gearth.ui.scheduler.listeners;
|
package gearth.services.scheduler.listeners;
|
||||||
|
|
||||||
public interface OnUpdatedListener {
|
public interface OnUpdatedListener {
|
||||||
void onUpdated();
|
void onUpdated();
|
@ -6,18 +6,17 @@ import javafx.scene.control.TabPane;
|
|||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import gearth.protocol.HConnection;
|
import gearth.protocol.HConnection;
|
||||||
import gearth.ui.connection.Connection;
|
import gearth.ui.connection.ConnectionController;
|
||||||
import gearth.ui.extensions.Extensions;
|
import gearth.ui.extensions.ExtensionsController;
|
||||||
import gearth.ui.info.Info;
|
import gearth.ui.info.InfoController;
|
||||||
import gearth.ui.injection.Injection;
|
import gearth.ui.injection.InjectionController;
|
||||||
import gearth.ui.logger.Logger;
|
import gearth.ui.logger.LoggerController;
|
||||||
import gearth.ui.scheduler.Scheduler;
|
import gearth.ui.scheduler.SchedulerController;
|
||||||
import gearth.ui.extra.Extra;
|
import gearth.ui.extra.ExtraController;
|
||||||
import gearth.ui.tools.Tools;
|
import gearth.ui.tools.ToolsController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class GEarthController {
|
public class GEarthController {
|
||||||
|
|
||||||
@ -27,14 +26,14 @@ public class GEarthController {
|
|||||||
private volatile HConnection hConnection;
|
private volatile HConnection hConnection;
|
||||||
private volatile int initcount = 0;
|
private volatile int initcount = 0;
|
||||||
|
|
||||||
public Connection connectionController;
|
public ConnectionController connectionController;
|
||||||
public Injection injectionController;
|
public InjectionController injectionController;
|
||||||
public Logger loggerController;
|
public LoggerController loggerController;
|
||||||
public Tools toolsController;
|
public ToolsController toolsController;
|
||||||
public Scheduler schedulerController;
|
public SchedulerController schedulerController;
|
||||||
public Extra extraController;
|
public ExtraController extraController;
|
||||||
public Info infoController;
|
public InfoController infoController;
|
||||||
public Extensions extensionsController;
|
public ExtensionsController extensionsController;
|
||||||
|
|
||||||
private List<SubForm> tabs = null;
|
private List<SubForm> tabs = null;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class Connection extends SubForm {
|
public class ConnectionController extends SubForm {
|
||||||
|
|
||||||
public ComboBox<String> inpPort;
|
public ComboBox<String> inpPort;
|
||||||
public ComboBox<String> inpHost;
|
public ComboBox<String> inpHost;
|
@ -21,7 +21,7 @@ import java.io.File;
|
|||||||
* Created by Jonas on 06/04/18.
|
* Created by Jonas on 06/04/18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Extensions extends SubForm {
|
public class ExtensionsController extends SubForm {
|
||||||
|
|
||||||
|
|
||||||
public Button btn_install;
|
public Button btn_install;
|
@ -4,16 +4,14 @@ import gearth.misc.Cacher;
|
|||||||
import gearth.protocol.HConnection;
|
import gearth.protocol.HConnection;
|
||||||
import gearth.protocol.misc.ConnectionInfoOverrider;
|
import gearth.protocol.misc.ConnectionInfoOverrider;
|
||||||
import gearth.ui.SubForm;
|
import gearth.ui.SubForm;
|
||||||
import gearth.ui.info.Info;
|
import gearth.ui.info.InfoController;
|
||||||
import javafx.beans.InvalidationListener;
|
|
||||||
import javafx.beans.Observable;
|
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Jonas on 06/04/18.
|
* Created by Jonas on 06/04/18.
|
||||||
*/
|
*/
|
||||||
public class Extra extends SubForm implements ConnectionInfoOverrider {
|
public class ExtraController extends SubForm implements ConnectionInfoOverrider {
|
||||||
|
|
||||||
public static final String NOTEPAD_CACHE_KEY = "notepad_text";
|
public static final String NOTEPAD_CACHE_KEY = "notepad_text";
|
||||||
|
|
||||||
@ -40,7 +38,7 @@ public class Extra extends SubForm implements ConnectionInfoOverrider {
|
|||||||
HConnection.setConnectionInfoOverrider(this);
|
HConnection.setConnectionInfoOverrider(this);
|
||||||
|
|
||||||
url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting"));
|
url_troubleshooting.setTooltip(new Tooltip("https://github.com/sirjonasxx/G-Earth/wiki/Troubleshooting"));
|
||||||
Info.activateHyperlink(url_troubleshooting);
|
InfoController.activateHyperlink(url_troubleshooting);
|
||||||
|
|
||||||
String notepadInitValue = (String)Cacher.get(NOTEPAD_CACHE_KEY);
|
String notepadInitValue = (String)Cacher.get(NOTEPAD_CACHE_KEY);
|
||||||
if (notepadInitValue != null) {
|
if (notepadInitValue != null) {
|
@ -12,7 +12,7 @@ import javafx.scene.image.ImageView;
|
|||||||
/**
|
/**
|
||||||
* Created by Jonas on 06/04/18.
|
* Created by Jonas on 06/04/18.
|
||||||
*/
|
*/
|
||||||
public class Info extends SubForm {
|
public class InfoController extends SubForm {
|
||||||
public ImageView img_logo;
|
public ImageView img_logo;
|
||||||
public Hyperlink link_sng;
|
public Hyperlink link_sng;
|
||||||
public Hyperlink link_darkbox;
|
public Hyperlink link_darkbox;
|
@ -13,7 +13,7 @@ import gearth.ui.SubForm;
|
|||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class Injection extends SubForm {
|
public class InjectionController extends SubForm {
|
||||||
public TextArea inputPacket;
|
public TextArea inputPacket;
|
||||||
public Text lbl_corrruption;
|
public Text lbl_corrruption;
|
||||||
public Text lbl_pcktInfo;
|
public Text lbl_pcktInfo;
|
@ -17,7 +17,7 @@ import gearth.ui.logger.loggerdisplays.PacketLoggerFactory;
|
|||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
public class Logger extends SubForm {
|
public class LoggerController extends SubForm {
|
||||||
|
|
||||||
|
|
||||||
public TextField txtPacketLimit;
|
public TextField txtPacketLimit;
|
@ -0,0 +1,54 @@
|
|||||||
|
package gearth.ui.scheduler;
|
||||||
|
|
||||||
|
import gearth.misc.listenerpattern.Observable;
|
||||||
|
import gearth.protocol.HMessage;
|
||||||
|
import gearth.protocol.HPacket;
|
||||||
|
import gearth.services.scheduler.Interval;
|
||||||
|
import gearth.services.scheduler.ScheduleItem;
|
||||||
|
import gearth.services.scheduler.listeners.OnBeingUpdatedListener;
|
||||||
|
import gearth.services.scheduler.listeners.OnDeleteListener;
|
||||||
|
import gearth.services.scheduler.listeners.OnEditListener;
|
||||||
|
import gearth.services.scheduler.listeners.OnUpdatedListener;
|
||||||
|
|
||||||
|
public class InteractableScheduleItem extends ScheduleItem {
|
||||||
|
public InteractableScheduleItem(int index, boolean paused, Interval delay, HPacket packet, HMessage.Direction destination) {
|
||||||
|
super(index, paused, delay, packet, destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InteractableScheduleItem(String stringifyAbleRepresentation) {
|
||||||
|
super(stringifyAbleRepresentation);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Observable<OnDeleteListener> onDeleteObservable = new Observable<>(OnDeleteListener::onDelete);
|
||||||
|
public void onDelete(OnDeleteListener listener) {
|
||||||
|
onDeleteObservable.addListener(listener);
|
||||||
|
}
|
||||||
|
public void delete() {
|
||||||
|
onDeleteObservable.fireEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Observable<OnEditListener> onEditObservable = new Observable<>(OnEditListener::onEdit);
|
||||||
|
public void onEdit(OnEditListener listener) {
|
||||||
|
onEditObservable.addListener(listener);
|
||||||
|
}
|
||||||
|
public void edit() {
|
||||||
|
onEditObservable.fireEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Observable<OnUpdatedListener> onUpdatedObservable = new Observable<>(OnUpdatedListener::onUpdated);
|
||||||
|
public void onIsupdated(OnUpdatedListener listener) {
|
||||||
|
onUpdatedObservable.addListener(listener);
|
||||||
|
}
|
||||||
|
public void isUpdatedTrigger() {
|
||||||
|
onUpdatedObservable.fireEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Observable<OnBeingUpdatedListener> onBeingUpdatedObservable = new Observable<>(OnBeingUpdatedListener::onBeingUpdated);
|
||||||
|
public void onIsBeingUpdated(OnBeingUpdatedListener listener) {
|
||||||
|
onBeingUpdatedObservable.addListener(listener);
|
||||||
|
}
|
||||||
|
public void onIsBeingUpdatedTrigger() {
|
||||||
|
onBeingUpdatedObservable.fireEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package gearth.ui.scheduler;
|
package gearth.ui.scheduler;
|
||||||
|
|
||||||
import javafx.beans.InvalidationListener;
|
import gearth.services.scheduler.ScheduleItem;
|
||||||
import javafx.beans.Observable;
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
@ -19,7 +18,7 @@ import gearth.ui.buttons.PauseResumeButton;
|
|||||||
public class ScheduleItemContainer extends GridPane {
|
public class ScheduleItemContainer extends GridPane {
|
||||||
|
|
||||||
public static final int[] columnWidths = {10, 39, 16, 18, 15};
|
public static final int[] columnWidths = {10, 39, 16, 18, 15};
|
||||||
ScheduleItem item;
|
InteractableScheduleItem item;
|
||||||
|
|
||||||
Label indexLabel;
|
Label indexLabel;
|
||||||
Label packetLabel;
|
Label packetLabel;
|
||||||
@ -28,7 +27,7 @@ public class ScheduleItemContainer extends GridPane {
|
|||||||
|
|
||||||
VBox parent;
|
VBox parent;
|
||||||
|
|
||||||
ScheduleItemContainer(ScheduleItem item, VBox parent, ScrollPane scrollPane) {
|
ScheduleItemContainer(InteractableScheduleItem item, VBox parent, ScrollPane scrollPane) {
|
||||||
super();
|
super();
|
||||||
setGridLinesVisible(true);
|
setGridLinesVisible(true);
|
||||||
VBox.setMargin(this, new Insets(2, -2, -2, -2));
|
VBox.setMargin(this, new Insets(2, -2, -2, -2));
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package gearth.ui.scheduler;
|
package gearth.ui.scheduler;
|
||||||
|
|
||||||
import com.tulskiy.keymaster.common.Provider;
|
import com.tulskiy.keymaster.common.Provider;
|
||||||
|
import gearth.services.scheduler.Interval;
|
||||||
|
import gearth.services.scheduler.ScheduleItem;
|
||||||
|
import gearth.services.scheduler.Scheduler;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
@ -21,7 +24,7 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* Created by Jonas on 06/04/18.
|
* Created by Jonas on 06/04/18.
|
||||||
*/
|
*/
|
||||||
public class Scheduler extends SubForm {
|
public class SchedulerController extends SubForm {
|
||||||
|
|
||||||
private static final Interval defaultInterval = new Interval(0, 500);
|
private static final Interval defaultInterval = new Interval(0, 500);
|
||||||
private static final HPacket defaultPacket = new HPacket(0);
|
private static final HPacket defaultPacket = new HPacket(0);
|
||||||
@ -44,9 +47,9 @@ public class Scheduler extends SubForm {
|
|||||||
|
|
||||||
public CheckBox cbx_hotkeys;
|
public CheckBox cbx_hotkeys;
|
||||||
|
|
||||||
private ScheduleItem isBeingEdited = null;
|
private InteractableScheduleItem isBeingEdited = null;
|
||||||
|
|
||||||
private List<ScheduleItem> scheduleItemList = new ArrayList<>();
|
private Scheduler<InteractableScheduleItem> scheduler = null;
|
||||||
|
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
@ -62,49 +65,6 @@ public class Scheduler extends SubForm {
|
|||||||
|
|
||||||
updateUI();
|
updateUI();
|
||||||
|
|
||||||
new Thread(() -> {
|
|
||||||
long t = System.currentTimeMillis();
|
|
||||||
long changed = 1;
|
|
||||||
|
|
||||||
Set<ScheduleItem> set = new HashSet<>();
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
set.clear();
|
|
||||||
for (int i = scheduleItemList.size() - 1; i >= 0; i--) {
|
|
||||||
set.add(scheduleItemList.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ScheduleItem item : set) {
|
|
||||||
if (!item.getPausedProperty().get()) {
|
|
||||||
Interval cur = item.getDelayProperty().get();
|
|
||||||
for (int i = 0; i < changed; i++) {
|
|
||||||
if ((t - i) % cur.getDelay() == cur.getOffset()) {
|
|
||||||
if (item.getDestinationProperty().get() == HMessage.Direction.TOSERVER) {
|
|
||||||
getHConnection().sendToServerAsync(item.getPacketProperty().get());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
getHConnection().sendToClientAsync(item.getPacketProperty().get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
long newT = System.currentTimeMillis();
|
|
||||||
changed = newT - t;
|
|
||||||
t = newT;
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//register hotkeys
|
//register hotkeys
|
||||||
//disable some output things
|
//disable some output things
|
||||||
PrintStream err = System.err;
|
PrintStream err = System.err;
|
||||||
@ -121,9 +81,14 @@ public class Scheduler extends SubForm {
|
|||||||
System.setErr(err);
|
System.setErr(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onParentSet() {
|
||||||
|
scheduler = new Scheduler<>(getHConnection());
|
||||||
|
}
|
||||||
|
|
||||||
private void switchPauseHotkey(int index) {
|
private void switchPauseHotkey(int index) {
|
||||||
if (cbx_hotkeys.isSelected() && index < scheduleItemList.size()) {
|
if (cbx_hotkeys.isSelected() && index < scheduler.size()) {
|
||||||
scheduleItemList.get(index).getPausedProperty().set(!scheduleItemList.get(index).getPausedProperty().get());
|
scheduler.get(index).getPausedProperty().set(!scheduler.get(index).getPausedProperty().get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +111,8 @@ public class Scheduler extends SubForm {
|
|||||||
HPacket packet = new HPacket(txt_packet.getText());
|
HPacket packet = new HPacket(txt_packet.getText());
|
||||||
if (packet.isCorrupted()) return;
|
if (packet.isCorrupted()) return;
|
||||||
|
|
||||||
ScheduleItem newItem = new ScheduleItem(
|
InteractableScheduleItem newItem = new InteractableScheduleItem(
|
||||||
scheduleItemList.size(),
|
scheduler.size(),
|
||||||
false,
|
false,
|
||||||
new Interval(txt_delay.getText()),
|
new Interval(txt_delay.getText()),
|
||||||
new HPacket(txt_packet.getText()),
|
new HPacket(txt_packet.getText()),
|
||||||
@ -168,9 +133,9 @@ public class Scheduler extends SubForm {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addItem(ScheduleItem newItem) {
|
private void addItem(InteractableScheduleItem newItem) {
|
||||||
new ScheduleItemContainer(newItem, schedulecontainer, scrollpane);
|
new ScheduleItemContainer(newItem, schedulecontainer, scrollpane);
|
||||||
scheduleItemList.add(newItem);
|
scheduler.add(newItem);
|
||||||
|
|
||||||
|
|
||||||
newItem.onDelete(() -> {
|
newItem.onDelete(() -> {
|
||||||
@ -178,9 +143,9 @@ public class Scheduler extends SubForm {
|
|||||||
setInputDefault();
|
setInputDefault();
|
||||||
isBeingEdited = null;
|
isBeingEdited = null;
|
||||||
}
|
}
|
||||||
scheduleItemList.remove(newItem);
|
scheduler.remove(newItem);
|
||||||
for (int i = 0; i < scheduleItemList.size(); i++) {
|
for (int i = 0; i < scheduler.size(); i++) {
|
||||||
scheduleItemList.get(i).getIndexProperty().set(i);
|
scheduler.get(i).getIndexProperty().set(i);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
newItem.onEdit(() -> {
|
newItem.onEdit(() -> {
|
||||||
@ -219,14 +184,14 @@ public class Scheduler extends SubForm {
|
|||||||
|
|
||||||
|
|
||||||
private void clear() {
|
private void clear() {
|
||||||
for (int i = scheduleItemList.size() - 1; i >= 0; i--) {
|
for (int i = scheduler.size() - 1; i >= 0; i--) {
|
||||||
scheduleItemList.get(i).delete();
|
scheduler.get(i).delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void load(List<ScheduleItem> list) {
|
private void load(List<InteractableScheduleItem> list) {
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
for (ScheduleItem item : list) {
|
for (InteractableScheduleItem item : list) {
|
||||||
addItem(item);
|
addItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,9 +219,9 @@ public class Scheduler extends SubForm {
|
|||||||
FileWriter fileWriter = new FileWriter(file);
|
FileWriter fileWriter = new FileWriter(file);
|
||||||
BufferedWriter out = new BufferedWriter(fileWriter);
|
BufferedWriter out = new BufferedWriter(fileWriter);
|
||||||
|
|
||||||
for (int i = 0; i < scheduleItemList.size(); i++) {
|
for (int i = 0; i < scheduler.size(); i++) {
|
||||||
out.write(scheduleItemList.get(i).stringify());
|
out.write(scheduler.get(i).stringify());
|
||||||
if (i != scheduleItemList.size() - 1) out.write("\n");
|
if (i != scheduler.size() - 1) out.write("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
out.flush();
|
out.flush();
|
||||||
@ -270,7 +235,7 @@ public class Scheduler extends SubForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadBtnClicked(ActionEvent actionEvent) {
|
public void loadBtnClicked(ActionEvent actionEvent) {
|
||||||
List<ScheduleItem> list = new ArrayList<>();
|
List<InteractableScheduleItem> list = new ArrayList<>();
|
||||||
|
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
fileChooser.setTitle("Load Schedule File");
|
fileChooser.setTitle("Load Schedule File");
|
||||||
@ -287,7 +252,7 @@ public class Scheduler extends SubForm {
|
|||||||
|
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
list.add(new ScheduleItem(line));
|
list.add(new InteractableScheduleItem(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
fr.close();
|
fr.close();
|
@ -11,7 +11,7 @@ import gearth.ui.SubForm;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
|
||||||
public class Tools extends SubForm {
|
public class ToolsController extends SubForm {
|
||||||
public TextField txt_intDecoded;
|
public TextField txt_intDecoded;
|
||||||
public TextField txt_intEncoded;
|
public TextField txt_intEncoded;
|
||||||
public TextField txt_ushortDecoded;
|
public TextField txt_ushortDecoded;
|
@ -11,7 +11,7 @@
|
|||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<GridPane alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.131" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.connection.Connection">
|
<GridPane alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.131" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.connection.ConnectionController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
|
||||||
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
|
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="gearth.ui.extensions.Extensions">
|
fx:controller="gearth.ui.extensions.ExtensionsController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="277.0"/>
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="277.0"/>
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.extra.Extra">
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.extra.ExtraController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="331.0" minWidth="10.0" prefWidth="318.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="331.0" minWidth="10.0" prefWidth="318.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="247.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="247.0" />
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="595.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.info.Info">
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="595.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.info.InfoController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="332.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="332.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<?import javafx.scene.text.TextFlow?>
|
<?import javafx.scene.text.TextFlow?>
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
|
||||||
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
|
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="gearth.ui.injection.Injection">
|
fx:controller="gearth.ui.injection.InjectionController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
|
||||||
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
|
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="gearth.ui.logger.Logger">
|
fx:controller="gearth.ui.logger.LoggerController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="293.0" minWidth="10.0" prefWidth="242.0"/>
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="293.0" minWidth="10.0" prefWidth="242.0"/>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="323.0"/>
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="390.0" minWidth="10.0" prefWidth="323.0"/>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="595.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.scheduler.Scheduler">
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="595.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gearth.ui.scheduler.SchedulerController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="277.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="277.0" />
|
||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="262.0" prefWidth="565.0"
|
||||||
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
|
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="gearth.ui.tools.Tools">
|
fx:controller="gearth.ui.tools.ToolsController">
|
||||||
<rowConstraints>
|
<rowConstraints>
|
||||||
<RowConstraints maxHeight="158.0" minHeight="10.0" prefHeight="134.0" vgrow="SOMETIMES"/>
|
<RowConstraints maxHeight="158.0" minHeight="10.0" prefHeight="134.0" vgrow="SOMETIMES"/>
|
||||||
<RowConstraints maxHeight="141.0" minHeight="10.0" prefHeight="128.0" vgrow="SOMETIMES"/>
|
<RowConstraints maxHeight="141.0" minHeight="10.0" prefHeight="128.0" vgrow="SOMETIMES"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user