diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index def6a6a..94a25f7 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,7 +1,6 @@
-
+
-
-
+
\ No newline at end of file
diff --git a/src/main/java/Controller.java b/src/main/java/Controller.java
index 92338ef..abed79c 100644
--- a/src/main/java/Controller.java
+++ b/src/main/java/Controller.java
@@ -1,19 +1,18 @@
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamApp;
import com.jfoenix.controls.*;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
-import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Tooltip;
import javafx.stage.FileChooser;
import org.apache.commons.configuration2.ex.ConfigurationException;
-import javax.swing.*;
import java.io.File;
import java.io.IOException;
public class Controller {
- public JFXButton path_button;
private CreamApiConfig config = CreamApiConfig.getInstance();
private SteamAppsListCache cache = new SteamAppsListCache();
@FXML public JFXTextField path_textfield;
@@ -27,14 +26,18 @@ public class Controller {
@FXML public JFXButton reset_button;
@FXML public JFXButton save_button;
@FXML public JFXButton getAppId_button;
+ @FXML public JFXButton path_button;
+ @FXML public JFXButton retrieveDlcList_button;
public Controller() {}
@FXML
public void initialize() {
- read();
+ appId_textfield.textProperty().addListener(appIdChangesGameName());
+ retrieveDlcList_button.setDisable(true); // WIP
generate_tooltips();
fix_dlc_textarea_prompt_text();
+ read();
}
private void read() {
@@ -59,6 +62,23 @@ public class Controller {
Tooltip.install(extra_protection_checkbox, extra_protection_tooltip);
}
+ private ChangeListener appIdChangesGameName() {
+ return (observable, oldValue, newValue) -> {
+ int appId;
+ try {
+ appId = Integer.parseInt(newValue);
+ final SteamApp game = cache.getGame(appId);
+ if (game != null) {
+ game_name_textfield.setText(game.getName());
+ } else {
+ game_name_textfield.setText("");
+ }
+ } catch (NumberFormatException e) {
+ game_name_textfield.setText("");
+ }
+ };
+ }
+
public void reset() {
config.read();
read();
@@ -79,7 +99,7 @@ public class Controller {
}
public void getAppId() {
- final SteamApp game = cache.getGame(game_name_textfield.getText());
+ final SteamApp game = cache.searchGame(game_name_textfield.getText());
if (game == null) {
appId_textfield.setText("-1");
} else {
diff --git a/src/main/java/SteamAppsListCache.java b/src/main/java/SteamAppsListCache.java
index dd57a86..38fa235 100644
--- a/src/main/java/SteamAppsListCache.java
+++ b/src/main/java/SteamAppsListCache.java
@@ -49,6 +49,15 @@ public class SteamAppsListCache {
return null;
}
+ public SteamApp searchGame(String name) {
+ for (SteamApp app : list.steamAppsList) {
+ if (app.getName().toLowerCase().contains(name.toLowerCase())) {
+ return app;
+ }
+ }
+ return null;
+ }
+
private void getListFromApi() {
SteamWebApiClient client = new SteamWebApiClient();
SteamApps steamApps = new SteamApps(client);
diff --git a/src/main/resources/mainWindow.fxml b/src/main/resources/mainWindow.fxml
index 32f59ec..fbb9b04 100644
--- a/src/main/resources/mainWindow.fxml
+++ b/src/main/resources/mainWindow.fxml
@@ -39,7 +39,7 @@
-
+
@@ -48,6 +48,7 @@
+