Skip to content

Commit 8660267

Browse files
authored
Player - закрытие по Escape и запуск реплея через аргумент (#7)
* Python bot init talks with server * Python talk with server up to started match * Python starter bot client done * - Fixed socket read buffer - Named tuple XY and BotInfo * - Revert back to dataclasses (faster) * - Socket - skip server round data to stay in sync * - README - bot comments - optimized Socket performance * - more Type annotations * - fixed map size XY type (str -> int) * better str -> int type conversion * - Player close on Escape - Player open replay file from argument
1 parent bfea897 commit 8660267

File tree

1 file changed

+22
-0
lines changed
  • player/src/main/java/ru/croccode/hypernull/player

1 file changed

+22
-0
lines changed

player/src/main/java/ru/croccode/hypernull/player/App.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
import java.nio.file.Files;
77
import java.nio.file.Path;
88
import java.util.ArrayList;
9+
import java.util.Arrays;
10+
import java.util.Collections;
911
import java.util.List;
1012
import java.util.concurrent.Executors;
1113
import java.util.concurrent.ScheduledExecutorService;
1214
import java.util.function.Predicate;
1315

1416
import javafx.application.Application;
17+
import javafx.event.EventHandler;
1518
import javafx.geometry.Pos;
1619
import javafx.scene.Scene;
1720
import javafx.scene.input.Dragboard;
21+
import javafx.scene.input.KeyCode;
22+
import javafx.scene.input.KeyEvent;
1823
import javafx.scene.input.TransferMode;
1924
import javafx.scene.layout.Priority;
2025
import javafx.scene.layout.StackPane;
@@ -95,6 +100,13 @@ public void start(Stage primaryStage) {
95100
});
96101

97102
Scene scene = new Scene(vbox);
103+
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
104+
public void handle(KeyEvent ke) {
105+
if (ke.getCode() == KeyCode.ESCAPE) {
106+
primaryStage.close();
107+
}
108+
}
109+
});
98110
URL style = getClass().getResource("/style.css");
99111
if (style != null) {
100112
scene.getStylesheets().add(style.toExternalForm());
@@ -104,6 +116,16 @@ public void start(Stage primaryStage) {
104116
primaryStage.setMinWidth(800);
105117
primaryStage.setMinHeight(600);
106118
primaryStage.show();
119+
120+
List<String> args = getParameters().getRaw();
121+
if (!args.isEmpty()) {
122+
List<File> file = Collections.singletonList(new File(args.get(0)));
123+
try {
124+
queueReplays(file);
125+
} catch (IOException ex) {
126+
ex.printStackTrace();
127+
}
128+
}
107129
}
108130

109131
@Override

0 commit comments

Comments
 (0)