"Get list of DLC" function now implemented
List of Steam games are now pulled from another API (IStoreService) Create steamapps.json if missing (needed on first run) Improved Search function Code Improvements
This commit is contained in:
parent
14408cd9a6
commit
c7911a1eef
1
.gitignore
vendored
1
.gitignore
vendored
@ -157,3 +157,4 @@ $RECYCLE.BIN/
|
|||||||
|
|
||||||
cream_api.ini
|
cream_api.ini
|
||||||
steamapps.json
|
steamapps.json
|
||||||
|
/test.json
|
||||||
|
@ -18,39 +18,16 @@
|
|||||||
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
|
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.4" level="project" />
|
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.4" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
|
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.ibasco.agql:agql-steam-webapi:0.1.7" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.ibasco.agql:agql-lib-core:0.1.7" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.guava:guava:23.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.0.18" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.asynchttpclient:async-http-client:2.5.4" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.asynchttpclient:async-http-client-netty-utils:2.5.4" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-codec-http:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-codec-socks:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-handler-proxy:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-epoll:linux-x86_64:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver-dns:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: io.netty:netty-codec-dns:4.1.30.Final" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.2" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.typesafe.netty:netty-reactive-streams:2.0.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: com.sun.activation:javax.activation:1.2.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.junit.jupiter:junit-jupiter-api:5.6.0-M1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.junit.platform:junit-platform-commons:1.6.0-M1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: de.jensd:fontawesomefx-commons:8.15" level="project" />
|
<orderEntry type="library" name="Maven: de.jensd:fontawesomefx-commons:8.15" level="project" />
|
||||||
<orderEntry type="library" name="Maven: de.jensd:fontawesomefx-fontawesome:4.7.0-5" level="project" />
|
<orderEntry type="library" name="Maven: de.jensd:fontawesomefx-fontawesome:4.7.0-5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jsoup:jsoup:1.12.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.konghq:unirest-java:3.1.02" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.9" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.11" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.5.9" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpasyncclient:4.1.4" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore-nio:4.4.10" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
46
pom.xml
46
pom.xml
@ -51,6 +51,27 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<id>bintray-jerady-maven</id>
|
||||||
|
<name>bintray</name>
|
||||||
|
<url>https://dl.bintray.com/jerady/maven</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<id>bintray-jerady-maven</id>
|
||||||
|
<name>bintray-plugins</name>
|
||||||
|
<url>https://dl.bintray.com/jerady/maven</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jfoenix</groupId>
|
<groupId>com.jfoenix</groupId>
|
||||||
@ -58,11 +79,6 @@
|
|||||||
<version>8.0.8</version>
|
<version>8.0.8</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--dependency>
|
|
||||||
<groupId>org.ini4j</groupId>
|
|
||||||
<artifactId>ini4j</artifactId>
|
|
||||||
<version>0.5.4</version>
|
|
||||||
</dependency-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-configuration2</artifactId>
|
<artifactId>commons-configuration2</artifactId>
|
||||||
@ -73,11 +89,6 @@
|
|||||||
<artifactId>commons-beanutils</artifactId>
|
<artifactId>commons-beanutils</artifactId>
|
||||||
<version>1.9.4</version>
|
<version>1.9.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.ibasco.agql</groupId>
|
|
||||||
<artifactId>agql-steam-webapi</artifactId>
|
|
||||||
<version>0.1.7</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.jensd</groupId>
|
<groupId>de.jensd</groupId>
|
||||||
<artifactId>fontawesomefx-commons</artifactId>
|
<artifactId>fontawesomefx-commons</artifactId>
|
||||||
@ -90,5 +101,20 @@
|
|||||||
<version>4.7.0-5</version>
|
<version>4.7.0-5</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jsoup</groupId>
|
||||||
|
<artifactId>jsoup</artifactId>
|
||||||
|
<version>1.12.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.konghq</groupId>
|
||||||
|
<artifactId>unirest-java</artifactId>
|
||||||
|
<version>3.1.02</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -1,39 +1,60 @@
|
|||||||
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamApp;
|
|
||||||
import com.jfoenix.controls.*;
|
import com.jfoenix.controls.*;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Tooltip;
|
import javafx.scene.control.Tooltip;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.jsoup.select.Elements;
|
||||||
|
import pojo.App;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Controller {
|
public class Controller {
|
||||||
private CreamApiConfig config = CreamApiConfig.getInstance();
|
private CreamApiConfig config = CreamApiConfig.getInstance();
|
||||||
private SteamAppsListCache cache = new SteamAppsListCache();
|
private SteamAppsListCache cache = new SteamAppsListCache();
|
||||||
@FXML public JFXTextField path_textfield;
|
@FXML
|
||||||
@FXML public JFXTextField appId_textfield;
|
public JFXTextField path_textfield;
|
||||||
@FXML public JFXTextField game_name_textfield;
|
@FXML
|
||||||
@FXML public JFXComboBox<String> language_combobox;
|
public JFXTextField appId_textfield;
|
||||||
@FXML public JFXTextArea dlc_textarea;
|
@FXML
|
||||||
@FXML public JFXCheckBox extra_protection_checkbox;
|
public JFXTextField game_name_textfield;
|
||||||
@FXML public JFXCheckBox offline_checkbox;
|
@FXML
|
||||||
@FXML public JFXCheckBox unlock_all_checkbox;
|
public JFXComboBox<String> language_combobox;
|
||||||
@FXML public JFXButton reset_button;
|
@FXML
|
||||||
@FXML public JFXButton save_button;
|
public JFXTextArea dlc_textarea;
|
||||||
@FXML public JFXButton getAppId_button;
|
@FXML
|
||||||
@FXML public JFXButton path_button;
|
public JFXCheckBox extra_protection_checkbox;
|
||||||
@FXML public JFXButton retrieveDlcList_button;
|
@FXML
|
||||||
|
public JFXCheckBox offline_checkbox;
|
||||||
|
@FXML
|
||||||
|
public JFXCheckBox unlock_all_checkbox;
|
||||||
|
@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() {}
|
public Controller() {
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
appId_textfield.textProperty().addListener(appIdChangesGameName());
|
appId_textfield.textProperty().addListener(appIdChangesGameName());
|
||||||
retrieveDlcList_button.setDisable(true); // WIP
|
//retrieveDlcList_button.setDisable(true); // WIP
|
||||||
generate_tooltips();
|
generate_tooltips();
|
||||||
fix_dlc_textarea_prompt_text();
|
fix_dlc_textarea_prompt_text();
|
||||||
read();
|
read();
|
||||||
@ -66,7 +87,7 @@ public class Controller {
|
|||||||
int appId;
|
int appId;
|
||||||
try {
|
try {
|
||||||
appId = Integer.parseInt(newValue);
|
appId = Integer.parseInt(newValue);
|
||||||
final SteamApp game = cache.getGame(appId);
|
final App game = cache.getGame(appId);
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
game_name_textfield.setText(game.getName());
|
game_name_textfield.setText(game.getName());
|
||||||
} else {
|
} else {
|
||||||
@ -98,72 +119,73 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getAppId() {
|
public void getAppId() {
|
||||||
final SteamApp game = cache.findGame(game_name_textfield.getText());
|
final App game = cache.findGame(game_name_textfield.getText());
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
appId_textfield.setText("-1");
|
appId_textfield.setText("-1");
|
||||||
} else {
|
} else {
|
||||||
appId_textfield.setText(String.valueOf(game.getAppid()));
|
appId_textfield.setText(String.valueOf(game.getAppId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unlockAll_disableDlcTextArea() {
|
public void unlockAll_disableDlcTextArea() {
|
||||||
dlc_textarea.setDisable(unlock_all_checkbox.isSelected());
|
dlc_textarea.setDisable(unlock_all_checkbox.isSelected());
|
||||||
|
retrieveDlcList_button.setDisable(unlock_all_checkbox.isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets DLC from both the Steam Store and SteamDB, since the latter has a (weird) limit of 64(?) DLCs. SteamDB
|
||||||
|
* also lists DLC not available for purchase.
|
||||||
|
*/
|
||||||
public void getDlcList() {
|
public void getDlcList() {
|
||||||
// https://github.com/Sak32009/GetDLCInfoFromSteamDB/blob/master/sak32009-get-dlc-info-from-steamdb.user.js
|
Map<Integer, String> steamStoreDLCs = new HashMap<>();
|
||||||
/*async getData() {
|
Map<Integer, String> steamDbDLCs = new HashMap<>();
|
||||||
// CHECK IF THE APPID HAS DLCs
|
//StringBuilder sb = new StringBuilder();
|
||||||
if (!$("#dlc").length) {
|
try {
|
||||||
return false;
|
// Steam Store
|
||||||
|
Document steamDoc = Jsoup
|
||||||
|
.connect("https://store.steampowered.com/app/" + appId_textfield.getText() + "/")
|
||||||
|
.get();
|
||||||
|
Elements steamDLCs = steamDoc.getElementsByClass("game_area_dlc_row");
|
||||||
|
for (Element dlc : steamDLCs) {
|
||||||
|
String dlc_id = dlc.attr("data-ds-appid");
|
||||||
|
String dlc_name = dlc
|
||||||
|
.getElementsByClass("game_area_dlc_name")
|
||||||
|
.text().replace("\n", "").trim();
|
||||||
|
steamStoreDLCs.put(Integer.parseInt(dlc_id), dlc_name);
|
||||||
}
|
}
|
||||||
// SELF
|
// SteamDB
|
||||||
const self = this;
|
Document steamDbDoc = Jsoup
|
||||||
// SET APPID
|
.connect("https://steamdb.info/app/" + appId_textfield.getText() + "/dlc/")
|
||||||
this.steamDB.appID = $(".scope-app[data-appid]").data("appid");
|
.get();
|
||||||
// SET APPID NAME
|
Element steamDbDlcSection = steamDbDoc.getElementById("dlc");
|
||||||
this.steamDB.appIDName = $("td[itemprop='name']").text();
|
Elements steamDbDLCElements = steamDbDlcSection.getElementsByClass("app");
|
||||||
// GET APPID DLCS FROM TAB
|
for (Element dlc : steamDbDLCElements) {
|
||||||
$("tr.app[data-appid]").each((_index, _values) => {
|
String dlc_id = dlc.attr("data-appid");
|
||||||
const $this = $(_values);
|
String dlc_name = "Unknown DLC " + dlc_id;
|
||||||
const appID = $this.data("appid");
|
Elements td = dlc.getElementsByTag("td");
|
||||||
const appIDName = $this.find(`td:nth-of-type(2)`).text().trim();
|
if (!td.isEmpty()) {
|
||||||
// ADD DATA
|
dlc_name = td.get(1).text().replace("\n", "").trim();
|
||||||
self.steamDB.appIDDLCs[appID] = {
|
|
||||||
name: appIDName
|
|
||||||
};
|
|
||||||
// +1
|
|
||||||
self.steamDB.appIDDLCsCount += 1;
|
|
||||||
});
|
|
||||||
// GET APPID DLCS FROM REQUEST
|
|
||||||
await this.getHttpRequest(`${self.info.steamDBLinked + this.steamDB.appID}`, ({
|
|
||||||
responseText
|
|
||||||
}) => {
|
|
||||||
// APPS
|
|
||||||
const $apps = $($.parseHTML(responseText)).find("tr.app[data-appid]");
|
|
||||||
// FETCH APPS
|
|
||||||
$apps.each((_index, _values) => {
|
|
||||||
const $this = $(_values);
|
|
||||||
const appID = $this.attr("data-appid");
|
|
||||||
const appIDType = $this.find("td:nth-of-type(2)").text().trim();
|
|
||||||
const appIDName = $this.find("td:nth-of-type(3)").text().trim();
|
|
||||||
// CHECK IF EXISTS
|
|
||||||
if (!(appID in self.steamDB.appIDDLCs) && appIDType === "DLC") {
|
|
||||||
// ADD DATA
|
|
||||||
self.steamDB.appIDDLCs[appID] = {
|
|
||||||
name: appIDName
|
|
||||||
};
|
|
||||||
// +1
|
|
||||||
self.steamDB.appIDDLCsCount += 1;
|
|
||||||
}
|
}
|
||||||
});
|
steamDbDLCs.put(Integer.parseInt(dlc_id), dlc_name);
|
||||||
// RUN
|
}
|
||||||
self.start();
|
} catch (IOException e) {
|
||||||
});
|
e.printStackTrace();
|
||||||
}*/
|
} catch (NullPointerException e) {
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openFileChooser(ActionEvent event) {
|
Map<Integer, String> allDLCs = new HashMap<>(steamStoreDLCs);
|
||||||
|
steamDbDLCs.forEach(allDLCs::putIfAbsent);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
LinkedHashMap<Number, String> collect = allDLCs.entrySet().stream()
|
||||||
|
.sorted(Map.Entry.comparingByKey())
|
||||||
|
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
|
||||||
|
(oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
||||||
|
collect.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n"));
|
||||||
|
dlc_textarea.setText(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openFileChooser() {
|
||||||
FileChooser chooser = new FileChooser();
|
FileChooser chooser = new FileChooser();
|
||||||
chooser.setTitle("Choose steam_api(64).dll...");
|
chooser.setTitle("Choose steam_api(64).dll...");
|
||||||
FileChooser.ExtensionFilter filter =
|
FileChooser.ExtensionFilter filter =
|
||||||
|
@ -1,58 +1,66 @@
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.ibasco.agql.protocols.valve.steam.webapi.SteamWebApiClient;
|
import kong.unirest.HttpResponse;
|
||||||
import com.ibasco.agql.protocols.valve.steam.webapi.interfaces.SteamApps;
|
import kong.unirest.Unirest;
|
||||||
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamApp;
|
import pojo.App;
|
||||||
|
import pojo.Download;
|
||||||
|
import pojo.SteamAppsList;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class SteamAppsListCache {
|
public class SteamAppsListCache {
|
||||||
|
|
||||||
static class SteamAppsList {
|
|
||||||
Instant timestamp;
|
|
||||||
List<SteamApp> steamAppsList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private SteamAppsList list = new SteamAppsList();
|
private SteamAppsList list = new SteamAppsList();
|
||||||
private File cacheFile = new File("steamapps.json");
|
private File cacheFile = new File("steamapps.json");
|
||||||
|
|
||||||
public SteamAppsListCache() {
|
public SteamAppsListCache() {
|
||||||
|
boolean fileFound = true;
|
||||||
|
try {
|
||||||
getListFromFile();
|
getListFromFile();
|
||||||
if (Instant.now().isAfter(list.timestamp.plus(Duration.ofDays(3)))) {
|
} catch (FileNotFoundException e) {
|
||||||
|
System.err.println("File does not exist, trying to create steamapps.json for the first time...");
|
||||||
|
fileFound = false;
|
||||||
|
}
|
||||||
|
if (!fileFound || Instant.now().isAfter(list.getTimestamp().plus(Duration.ofDays(3)))) {
|
||||||
|
sync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sync() {
|
||||||
getListFromApi();
|
getListFromApi();
|
||||||
|
try {
|
||||||
saveListToFile();
|
saveListToFile();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SteamApp getGame (int appId) {
|
public App getGame(int appId) {
|
||||||
for (SteamApp app : list.steamAppsList) {
|
return list.getSteamAppsList().stream().filter(app -> app.getAppId() == appId).findFirst().orElse(null);
|
||||||
if (app.getAppid() == appId) {
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public App getGame(String name) {
|
||||||
|
return list.getSteamAppsList().stream()
|
||||||
|
.filter(app -> app.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public App findGame(String name) {
|
||||||
|
for (App app : list.getSteamAppsList()) {
|
||||||
|
if (app.getName().toLowerCase().replaceAll("[^a-zA-Z0-9\\s+]", "")
|
||||||
|
.startsWith(name.toLowerCase().replaceAll("[^a-zA-Z0-9\\s+]", ""))) {
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
for (App app : list.getSteamAppsList()) {
|
||||||
}
|
if (app.getName().toLowerCase().replaceAll("[^a-zA-Z0-9\\s+]", "")
|
||||||
|
.contains(name.toLowerCase().replaceAll("[^a-zA-Z0-9\\s+]", ""))) {
|
||||||
public SteamApp getGame (String name) {
|
|
||||||
for (SteamApp app : list.steamAppsList) {
|
|
||||||
if (app.getName().equalsIgnoreCase(name)) {
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SteamApp findGame(String name) {
|
|
||||||
for (SteamApp app : list.steamAppsList) {
|
|
||||||
if (app.getName().toLowerCase().contains(name.toLowerCase())) {
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,44 +68,30 @@ public class SteamAppsListCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getListFromApi() {
|
private void getListFromApi() {
|
||||||
SteamWebApiClient client = new SteamWebApiClient();
|
HttpResponse<String> httpResponse =
|
||||||
SteamApps steamApps = new SteamApps(client);
|
Unirest.get("https://api.steampowered.com/IStoreService/GetAppList/v1/" +
|
||||||
/*SteamStorefront storefront = new SteamStorefront(client);
|
"?key=E427256C579D3CDF1D504810E8F5B948&include_games=1&max_results=50000").asString();
|
||||||
StoreAppDetails appDetails = storefront.getAppDetails(440).exceptionally(throwable -> {
|
List<App> apps = new Gson()
|
||||||
System.err.println(MessageFormat.format("Error Occurred: {}", throwable));
|
.fromJson(httpResponse.getBody(), Download.class)
|
||||||
return new StoreAppDetails();
|
.getResponse().getApps();
|
||||||
}).join();
|
list.setTimestamp(Instant.now());
|
||||||
System.out.println(appDetails);
|
list.setSteamAppsList(apps);
|
||||||
Gson gson = new Gson();
|
|
||||||
System.out.println(gson.toJson(appDetails));*/
|
|
||||||
list.timestamp = Instant.now();
|
|
||||||
list.steamAppsList = steamApps.getAppList().exceptionally(throwable -> {
|
|
||||||
System.err.println(MessageFormat.format("Error Occurred: {}", throwable));
|
|
||||||
return new ArrayList<>();
|
|
||||||
}).join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveListToFile() {
|
private void saveListToFile() throws IOException {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String jsonString = gson.toJson(list);
|
String jsonString = gson.toJson(list);
|
||||||
try {
|
|
||||||
BufferedWriter fOut = new BufferedWriter(new FileWriter(cacheFile));
|
BufferedWriter fOut = new BufferedWriter(new FileWriter(cacheFile));
|
||||||
fOut.write(jsonString);
|
fOut.write(jsonString);
|
||||||
fOut.close();
|
fOut.close();
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getListFromFile() {
|
private void getListFromFile() throws FileNotFoundException {
|
||||||
try {
|
|
||||||
BufferedReader fIn = new BufferedReader(new FileReader(cacheFile));
|
BufferedReader fIn = new BufferedReader(new FileReader(cacheFile));
|
||||||
String json = fIn.lines().collect(Collectors.joining());
|
String json = fIn.lines().collect(Collectors.joining());
|
||||||
final Type type = new TypeToken<SteamAppsList>() {}.getType();
|
final Type type = new TypeToken<SteamAppsList>() {
|
||||||
|
}.getType();
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
list = gson.fromJson(json, type);
|
list = gson.fromJson(json, type);
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
110
src/main/java/pojo/App.java
Normal file
110
src/main/java/pojo/App.java
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
package pojo;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class App {
|
||||||
|
|
||||||
|
@SerializedName("appid")
|
||||||
|
@Expose
|
||||||
|
private Integer appId;
|
||||||
|
@SerializedName("name")
|
||||||
|
@Expose
|
||||||
|
private String name;
|
||||||
|
@SerializedName("last_modified")
|
||||||
|
@Expose
|
||||||
|
private Integer lastModified;
|
||||||
|
@SerializedName("price_change_number")
|
||||||
|
@Expose
|
||||||
|
private Integer priceChangeNumber;
|
||||||
|
|
||||||
|
public Integer getAppId() {
|
||||||
|
return appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAppId(Integer appId) {
|
||||||
|
this.appId = appId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getLastModified() {
|
||||||
|
return lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastModified(Integer lastModified) {
|
||||||
|
this.lastModified = lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPriceChangeNumber() {
|
||||||
|
return priceChangeNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPriceChangeNumber(Integer priceChangeNumber) {
|
||||||
|
this.priceChangeNumber = priceChangeNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(App.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
|
||||||
|
sb.append("appid");
|
||||||
|
sb.append('=');
|
||||||
|
sb.append(((this.appId == null)?"<null>":this.appId));
|
||||||
|
sb.append(',');
|
||||||
|
sb.append("name");
|
||||||
|
sb.append('=');
|
||||||
|
sb.append(((this.name == null)?"<null>":this.name));
|
||||||
|
sb.append(',');
|
||||||
|
sb.append("lastModified");
|
||||||
|
sb.append('=');
|
||||||
|
sb.append(((this.lastModified == null)?"<null>":this.lastModified));
|
||||||
|
sb.append(',');
|
||||||
|
sb.append("priceChangeNumber");
|
||||||
|
sb.append('=');
|
||||||
|
sb.append(((this.priceChangeNumber == null)?"<null>":this.priceChangeNumber));
|
||||||
|
sb.append(',');
|
||||||
|
if (sb.charAt((sb.length()- 1)) == ',') {
|
||||||
|
sb.setCharAt((sb.length()- 1), ']');
|
||||||
|
} else {
|
||||||
|
sb.append(']');
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = 1;
|
||||||
|
result = ((result* 31)+((this.name == null)? 0 :this.name.hashCode()));
|
||||||
|
result = ((result* 31)+((this.lastModified == null)? 0 :this.lastModified.hashCode()));
|
||||||
|
result = ((result* 31)+((this.priceChangeNumber == null)? 0 :this.priceChangeNumber.hashCode()));
|
||||||
|
result = ((result* 31)+((this.appId == null)? 0 :this.appId.hashCode()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
if (other == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(other instanceof App)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
App rhs = ((App) other);
|
||||||
|
boolean b1 = Objects.equals(this.name, rhs.name);
|
||||||
|
boolean b2 = Objects.equals(this.lastModified, rhs.lastModified);
|
||||||
|
boolean b3 = Objects.equals(this.priceChangeNumber, rhs.priceChangeNumber);
|
||||||
|
boolean b4 = Objects.equals(this.appId, rhs.appId);
|
||||||
|
return b1 && b2 && b3 && b4;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
58
src/main/java/pojo/Download.java
Normal file
58
src/main/java/pojo/Download.java
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package pojo;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class Download {
|
||||||
|
|
||||||
|
@SerializedName("response")
|
||||||
|
@Expose
|
||||||
|
private Rezponze response;
|
||||||
|
|
||||||
|
public Rezponze getResponse() {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponse(Rezponze response) {
|
||||||
|
this.response = response;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(Download.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
|
||||||
|
sb.append("response");
|
||||||
|
sb.append('=');
|
||||||
|
sb.append(((this.response == null)?"<null>":this.response));
|
||||||
|
sb.append(',');
|
||||||
|
if (sb.charAt((sb.length()- 1)) == ',') {
|
||||||
|
sb.setCharAt((sb.length()- 1), ']');
|
||||||
|
} else {
|
||||||
|
sb.append(']');
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = 1;
|
||||||
|
result = ((result* 31)+((this.response == null)? 0 :this.response.hashCode()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
if (other == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(other instanceof Download)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Download rhs = ((Download) other);
|
||||||
|
return Objects.equals(this.response, rhs.response);
|
||||||
|
//return ((this.response == rhs.response)||((this.response!= null)&&this.response.equals(rhs.response)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
60
src/main/java/pojo/Rezponze.java
Normal file
60
src/main/java/pojo/Rezponze.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package pojo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
public class Rezponze {
|
||||||
|
|
||||||
|
@SerializedName("apps")
|
||||||
|
@Expose
|
||||||
|
private List<App> apps = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<App> getApps() {
|
||||||
|
return apps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApps(List<App> apps) {
|
||||||
|
this.apps = apps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(Rezponze.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
|
||||||
|
sb.append("apps");
|
||||||
|
sb.append('=');
|
||||||
|
sb.append(((this.apps == null)?"<null>":this.apps));
|
||||||
|
sb.append(',');
|
||||||
|
if (sb.charAt((sb.length()- 1)) == ',') {
|
||||||
|
sb.setCharAt((sb.length()- 1), ']');
|
||||||
|
} else {
|
||||||
|
sb.append(']');
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = 1;
|
||||||
|
result = ((result* 31)+((this.apps == null)? 0 :this.apps.hashCode()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
if (other == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(other instanceof Rezponze)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Rezponze rhs = ((Rezponze) other);
|
||||||
|
return Objects.equals(this.apps, rhs.apps);
|
||||||
|
//return ((this.apps == rhs.apps)||((this.apps!= null)&&this.apps.equals(rhs.apps)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
25
src/main/java/pojo/SteamAppsList.java
Normal file
25
src/main/java/pojo/SteamAppsList.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package pojo;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SteamAppsList {
|
||||||
|
private Instant timestamp;
|
||||||
|
private List<App> steamAppsList;
|
||||||
|
|
||||||
|
public Instant getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimestamp(Instant timestamp) {
|
||||||
|
this.timestamp = timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<App> getSteamAppsList() {
|
||||||
|
return steamAppsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSteamAppsList(List<App> steamAppsList) {
|
||||||
|
this.steamAppsList = steamAppsList;
|
||||||
|
}
|
||||||
|
}
|
@ -48,7 +48,7 @@
|
|||||||
<JFXCheckBox fx:id="extra_protection_checkbox" text="Try to bypass game-specific protection" GridPane.columnSpan="2147483647" GridPane.rowIndex="4" />
|
<JFXCheckBox fx:id="extra_protection_checkbox" text="Try to bypass game-specific protection" GridPane.columnSpan="2147483647" GridPane.rowIndex="4" />
|
||||||
<JFXCheckBox fx:id="unlock_all_checkbox" onAction="#unlockAll_disableDlcTextArea" text="Unlock all DLC (if possible)" GridPane.columnSpan="2147483647" GridPane.rowIndex="5" />
|
<JFXCheckBox fx:id="unlock_all_checkbox" onAction="#unlockAll_disableDlcTextArea" text="Unlock all DLC (if possible)" GridPane.columnSpan="2147483647" GridPane.rowIndex="5" />
|
||||||
<JFXTextArea fx:id="dlc_textarea" promptText="List of DLC..." GridPane.columnSpan="2147483647" GridPane.rowIndex="6" />
|
<JFXTextArea fx:id="dlc_textarea" promptText="List of DLC..." GridPane.columnSpan="2147483647" GridPane.rowIndex="6" />
|
||||||
<JFXButton fx:id="retrieveDlcList_button" maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" text="Get DLCs for AppID" GridPane.rowIndex="7" />
|
<JFXButton fx:id="retrieveDlcList_button" maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onAction="#getDlcList" text="Get DLCs for AppID" GridPane.rowIndex="7" />
|
||||||
<JFXButton fx:id="save_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#save" text="Save" GridPane.columnIndex="1" GridPane.rowIndex="7" />
|
<JFXButton fx:id="save_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#save" text="Save" GridPane.columnIndex="1" GridPane.rowIndex="7" />
|
||||||
<JFXButton fx:id="reset_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#reset" text="Reset" GridPane.columnIndex="2" GridPane.rowIndex="7" />
|
<JFXButton fx:id="reset_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#reset" text="Reset" GridPane.columnIndex="2" GridPane.rowIndex="7" />
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
Loading…
Reference in New Issue
Block a user