Skip to content

Commit

Permalink
Player - закрытие по Escape и запуск реплея через аргумент (#7)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Rush-iam authored Jul 2, 2022
1 parent bfea897 commit 8660267
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions player/src/main/java/ru/croccode/hypernull/player/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Predicate;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
Expand Down Expand Up @@ -95,6 +100,13 @@ public void start(Stage primaryStage) {
});

Scene scene = new Scene(vbox);
scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
public void handle(KeyEvent ke) {
if (ke.getCode() == KeyCode.ESCAPE) {
primaryStage.close();
}
}
});
URL style = getClass().getResource("/style.css");
if (style != null) {
scene.getStylesheets().add(style.toExternalForm());
Expand All @@ -104,6 +116,16 @@ public void start(Stage primaryStage) {
primaryStage.setMinWidth(800);
primaryStage.setMinHeight(600);
primaryStage.show();

List<String> args = getParameters().getRaw();
if (!args.isEmpty()) {
List<File> file = Collections.singletonList(new File(args.get(0)));
try {
queueReplays(file);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}

@Override
Expand Down

0 comments on commit 8660267

Please sign in to comment.