Skip to content

Commit

Permalink
Visual overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
st4s1k committed Mar 27, 2022
1 parent 55107cf commit 6a58521
Show file tree
Hide file tree
Showing 13 changed files with 1,244 additions and 400 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
gluon-license: ${{ secrets.GLUON_LICENSE }}

- name: Gluon Build
run: mvn -Pdesktop gluonfx:build
run: mvn gluonfx:compile gluonfx:link

- name: Create Release
id: create_release
Expand Down
12 changes: 8 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
<lombok.version>1.18.22</lombok.version>
<gson.version>2.9.0</gson.version>
<controlsfx.version>11.1.1</controlsfx.version>
<javafx-fxml.version>13.0.2</javafx-fxml.version>
<javafx-controls.version>13.0.2</javafx-controls.version>
<javafx-fxml.version>17</javafx-fxml.version>
<javafx-controls.version>17</javafx-controls.version>
<!-- plugins -->
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<gluonfx.plugin.version>1.0.12</gluonfx.plugin.version>
<javafx.plugin.version>0.0.8</javafx.plugin.version>
<sortpom.plugin.version>3.0.1</sortpom.plugin.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -97,6 +98,7 @@
<configuration>
<mainClass>com.st4s1k.leagueteamcomp.LeagueTeamCompApplication</mainClass>
<options>
<option>-agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image</option>
<option>--add-exports</option>
<option>javafx.base/com.sun.javafx.event=org.controlsfx.controls</option>
<option>--add-exports</option>
Expand Down Expand Up @@ -126,10 +128,12 @@
<list>com.st4s1k.leagueteamcomp.controller.LeagueTeamCompController</list>
</reflectionList>
<nativeImageArgs>
<nativeImageArg>--allow-incomplete-classpath</nativeImageArg>
<nativeImageArg>--add-exports</nativeImageArg>
<nativeImageArg>javafx.base/com.sun.javafx.event=org.controlsfx.controls</nativeImageArg>
<nativeImageArg>--add-exports</nativeImageArg>
<nativeImageArg>com.gluonhq.attach.util/com.gluonhq.attach.util.impl=com.st4s1k.leagueteamcomp</nativeImageArg>
<nativeImageArg>com.gluonhq.attach.util/com.gluonhq.attach.util.impl=com.st4s1k.leagueteamcomp
</nativeImageArg>
<nativeImageArg>--add-exports</nativeImageArg>
<nativeImageArg>javafx.base/com.sun.javafx.event=ALL-UNNAMED</nativeImageArg>
<nativeImageArg>--add-exports</nativeImageArg>
Expand All @@ -141,7 +145,7 @@
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<version>3.0.1</version>
<version>${sortpom.plugin.version}</version>
</plugin>

</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
package com.st4s1k.leagueteamcomp;

import com.google.gson.Gson;
import com.st4s1k.leagueteamcomp.controller.LeagueTeamCompController;
import com.st4s1k.leagueteamcomp.model.champion.Champions;
import com.st4s1k.leagueteamcomp.repository.ChampionRepository;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TabPane;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import lombok.SneakyThrows;

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.ResourceBundle;
import java.util.concurrent.CompletableFuture;

import static java.net.http.HttpResponse.BodyHandlers;
import static java.util.Objects.requireNonNull;

public class LeagueTeamCompApplication extends Application {

public static final String ICON_FILE_PATH = "icon.png";
public static final String FXML_FILE_PATH = "ltc-view.fxml";
public static final String BUNDLE_PATH = "com.st4s1k.leagueteamcomp.ltc-view";
Expand All @@ -31,42 +35,43 @@ public class LeagueTeamCompApplication extends Application {
private static final boolean WINDOW_IS_RESIZABLE = false;

public static void main(String[] args) {
System.setProperty("javafx.platform", "Desktop");
launch();
}

@Override
@SneakyThrows
public void start(Stage stage) {
preloadChampions();
TabPane root = FXMLLoader.load(
requireNonNull(getClass().getResource(FXML_FILE_PATH)),
ResourceBundle.getBundle(BUNDLE_PATH)
);
loadChampionData();
FXMLLoader loader = new FXMLLoader(getClass().getResource(FXML_FILE_PATH), ResourceBundle.getBundle(BUNDLE_PATH));
Parent root = loader.load();
LeagueTeamCompController controller = loader.getController();
controller.setStageAndSetupListeners(stage);
Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT);
stage.setScene(scene);
stage.getIcons().add(new Image(requireNonNull(getClass().getResourceAsStream(ICON_FILE_PATH))));
stage.setTitle(WINDOW_TITLE);
stage.setResizable(WINDOW_IS_RESIZABLE);
stage.setOnCloseRequest(event -> closeProgram());
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
}

@SneakyThrows
private void preloadChampions() {
Champions champions = getChampionsFromUrl();
ChampionRepository.init(champions);
private void loadChampionData() {
CompletableFuture.runAsync(() -> ChampionRepository.init(getChampionsFromUrl()));
}

@SneakyThrows
private Champions getChampionsFromUrl() {
private CompletableFuture<Champions> getChampionsFromUrl() {
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("http://cdn.merakianalytics.com/riot/lol/resources/latest/en-US/champions.json"))
.build();
String response = HttpClient.newHttpClient()
return HttpClient.newHttpClient()
.sendAsync(request, BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.join();
.thenApply(this::getChampions);
}

private Champions getChampions(String response) {
String json = "{\"champions\":" + response + "}";
Champions champions = new Gson().fromJson(json, Champions.class);
champions.getChampions().values()
Expand Down

This file was deleted.

Loading

0 comments on commit 6a58521

Please sign in to comment.