init commit

This commit is contained in:
Jeddunk 2019-11-04 06:32:24 +01:00
commit aa057fca91
16 changed files with 931 additions and 0 deletions

159
.gitignore vendored Normal file
View File

@ -0,0 +1,159 @@
# Created by https://www.gitignore.io/api/java,maven,windows,intellij
# Edit at https://www.gitignore.io/?templates=java,maven,windows,intellij
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/**/sonarlint/
# SonarQube Plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator/
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.gitignore.io/api/java,maven,windows,intellij
cream_api.ini
steamapps.json

16
.idea/checkstyle-idea.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CheckStyle-IDEA">
<option name="configuration">
<map>
<entry key="checkstyle-version" value="8.25" />
<entry key="copy-libs" value="true" />
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
<entry key="scan-before-checkin" value="false" />
<entry key="scanscope" value="JavaOnly" />
<entry key="suppress-errors" value="false" />
</map>
</option>
</component>
</project>

26
.idea/compiler.xml Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="auto-cream-api" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="auto-cream-api" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>

2
.idea/description.html Normal file
View File

@ -0,0 +1,2 @@
<html>Simple <b>JavaFX 2.0</b> application that includes simple .fxml file with attached controller and Main class to quick start. Artifact to build JavaFX application is provided.
</html>

7
.idea/encodings.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

16
.idea/misc.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectKey">
<option name="state" value="project://e79810c8-c5c8-43b1-b19c-90c1f4095425" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/auto-cream-api.iml" filepath="$PROJECT_DIR$/auto-cream-api.iml" />
</modules>
</component>
</project>

7
.idea/vcs.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>

56
auto-cream-api.iml Normal file
View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.jfoenix:jfoenix:8.0.8" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-configuration2:2.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.8" 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-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-fontawesome:4.7.0-5" level="project" />
</component>
</module>

94
pom.xml Normal file
View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.jeddunk</groupId>
<artifactId>auto-cream-api</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.jfoenix</groupId>
<artifactId>jfoenix</artifactId>
<version>8.0.8</version>
<scope>compile</scope>
</dependency>
<!--dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
</dependency-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-configuration2</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>com.ibasco.agql</groupId>
<artifactId>agql-steam-webapi</artifactId>
<version>0.1.7</version>
</dependency>
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx-commons</artifactId>
<version>8.15</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx-fontawesome</artifactId>
<version>4.7.0-5</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,162 @@
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamApp;
import com.jfoenix.controls.*;
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;
@FXML public JFXTextField appId_textfield;
@FXML public JFXTextField game_name_textfield;
@FXML public JFXComboBox<String> language_combobox;
@FXML public JFXTextArea dlc_textarea;
@FXML public JFXCheckBox extra_protection_checkbox;
@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;
public Controller() {}
@FXML
public void initialize() {
read();
generate_tooltips();
fix_dlc_textarea_prompt_text();
}
private void read() {
appId_textfield.setText(config.getAppId().toString());
dlc_textarea.setText(config.getDlcListAsString());
game_name_textfield.setText(cache.getGame(config.getAppId()).getName());
extra_protection_checkbox.setSelected(config.getExtraProtection());
offline_checkbox.setSelected(config.getForceOffline());
unlock_all_checkbox.setSelected(config.getUnlockAll());
language_combobox.setItems(FXCollections.observableArrayList(config.getLanguages()));
language_combobox.getSelectionModel().select(config.getLanguage());
unlockAll_disableDlcTextArea();
}
private void fix_dlc_textarea_prompt_text() {
dlc_textarea.setPromptText("List of DLC...\r0000 = DLC Name");
}
private void generate_tooltips() {
Tooltip extra_protection_tooltip = new Tooltip("\"extra protection\"");
extra_protection_checkbox.setTooltip(extra_protection_tooltip);
Tooltip.install(extra_protection_checkbox, extra_protection_tooltip);
}
public void reset() {
config.read();
read();
}
public void save() {
config.setDlcListFromString(dlc_textarea.getText());
config.setAppId(Integer.parseInt(appId_textfield.getText()));
config.setExtraProtection(extra_protection_checkbox.isSelected());
config.setForceOffline(offline_checkbox.isSelected());
config.setUnlockAll(unlock_all_checkbox.isSelected());
config.setLanguage(language_combobox.getValue());
try {
config.sync();
} catch (ConfigurationException e) {
e.printStackTrace();
}
}
public void getAppId() {
final SteamApp game = cache.getGame(game_name_textfield.getText());
if (game == null) {
appId_textfield.setText("-1");
} else {
appId_textfield.setText(String.valueOf(game.getAppid()));
}
}
public void unlockAll_disableDlcTextArea() {
dlc_textarea.setDisable(unlock_all_checkbox.isSelected());
}
public void getDlcList() {
// https://github.com/Sak32009/GetDLCInfoFromSteamDB/blob/master/sak32009-get-dlc-info-from-steamdb.user.js
/*async getData() {
// CHECK IF THE APPID HAS DLCs
if (!$("#dlc").length) {
return false;
}
// SELF
const self = this;
// SET APPID
this.steamDB.appID = $(".scope-app[data-appid]").data("appid");
// SET APPID NAME
this.steamDB.appIDName = $("td[itemprop='name']").text();
// GET APPID DLCS FROM TAB
$("tr.app[data-appid]").each((_index, _values) => {
const $this = $(_values);
const appID = $this.data("appid");
const appIDName = $this.find(`td:nth-of-type(2)`).text().trim();
// ADD DATA
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;
}
});
// RUN
self.start();
});
}*/
}
public void openFileChooser(ActionEvent event) {
FileChooser chooser = new FileChooser();
chooser.setTitle("Choose steam_api(64).dll...");
FileChooser.ExtensionFilter filter =
new FileChooser.ExtensionFilter("steam_api(64).dll",
"steam_api.dll", "steam_api64.dll");
chooser.getExtensionFilters().add(filter);
final File file = chooser.showOpenDialog(path_button.getScene().getWindow());
try {
config.setConfig(file.getParent() + "\\cream_api.ini");
path_textfield.setText(file.getParent());
} catch (ConfigurationException | IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,200 @@
import org.apache.commons.configuration2.INIConfiguration;
import org.apache.commons.configuration2.SubnodeConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Configurations;
import org.apache.commons.configuration2.ex.ConfigurationException;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.*;
@SuppressWarnings("WeakerAccess")
public class CreamApiConfig {
private static CreamApiConfig configInstance;
private static final Configurations CONFIGS = new Configurations();
private INIConfiguration config;
private String path = "cream_api.ini";
//private Ini ini;
private Integer appId;
private String language;
private Boolean unlockAll;
private Boolean extraProtection;
private Boolean forceOffline;
private Map<Integer, String> dlc = new HashMap<>();
private List<String> languages = new ArrayList<>();
private CreamApiConfig() {
try {
config = CONFIGS.ini(path);
config.setCommentLeadingCharsUsedInInput(";");
} catch (ConfigurationException e) {
e.printStackTrace();
}
/*try {
//ini = new Ini(new File("cream_api.ini"));
//Config iniConfig = Config.getGlobal().clone();
} catch (IOException e) {
System.err.println("Can't open \"cream_api.ini\"!");
e.printStackTrace();
}*/
// https://partner.steamgames.com/doc/store/localization#supported_languages
languages.add("english");
languages.add("latam");
languages.add("brazilian");
languages.add("german");
languages.add("french");
languages.add("italian");
languages.add("portuguese");
languages.add("spanish");
languages.add("russian");
languages.add("schinese");
languages.add("tchinese");
languages.add("japanese");
languages.add("koreana");
read();
}
public static synchronized CreamApiConfig getInstance() {
if (configInstance == null) {
configInstance = new CreamApiConfig();
}
return configInstance;
}
public void read() {
/*appId = ini.get("steam", "appid", int.class);
language = ini.get("steam", "language", String.class);
if (language == null) {
language = "english";
}
unlockAll = ini.get("steam", "unlockall", boolean.class);
extraProtection = ini.get("steam", "extraprotection", boolean.class);
forceOffline = ini.get("steam", "forceoffline", boolean.class);
Map<String, String> dlc_temp = ini.get("dlc");
for (Map.Entry<String, String> e: dlc_temp.entrySet())
dlc.put(Integer.parseInt(e.getKey()), e.getValue());*/
appId = config.getInt("steam.appid");
language = config.getString("steam.language");
if (language == null) {
language = "english";
}
unlockAll = config.getBoolean("steam.unlockall");
extraProtection = config.getBoolean("steam.extraprotection");
forceOffline = config.getBoolean("steam.forceoffline");
final SubnodeConfiguration dlc_section = config.getSection("dlc");
for (Iterator<String> it = dlc_section.getKeys(); it.hasNext(); ) {
String k = it.next();
final String v = dlc_section.getString(k);
dlc.put(Integer.parseInt(k), v);
}
}
public void sync() throws ConfigurationException {
/*ini.put("steam", "appid", appId);
ini.put("steam", "language", language);
ini.put("steam", "unlockall", unlockAll);
ini.put("steam", "extraprotection", extraProtection);
ini.put("steam", "forceoffline", forceOffline);
for (Map.Entry<Integer, String> e: dlc.entrySet()) {
ini.put("dlc", e.getKey().toString(), e.getValue());
}
ini.store();*/
FileBasedConfigurationBuilder<INIConfiguration> builder = CONFIGS.iniBuilder(path);
config = builder.getConfiguration();
config.setCommentLeadingCharsUsedInInput(";");
config.setProperty("steam.appid", appId);
config.setProperty("steam.language", language);
config.setProperty("steam.unlockall", unlockAll);
config.setProperty("steam.extraprotection", extraProtection);
config.setProperty("steam.forceoffline", forceOffline);
final SubnodeConfiguration dlc_section = config.getSection("dlc");
dlc_section.clear();
for (Map.Entry<Integer, String> e : this.dlc.entrySet()) {
config.setProperty("dlc." + e.getKey().toString(), e.getValue());
}
builder.save();
}
// DLC list parsing
public String getDlcListAsString() {
StringBuilder sb = new StringBuilder();
for (Map.Entry<Integer, String> e: dlc.entrySet()) {
sb.append(e.getKey());
sb.append("=");
sb.append(e.getValue());
sb.append("\r\n");
}
return sb.toString();
}
public void setDlcListFromString(String str) {
dlc.clear();
final String[] lines = str.split("\\R+");
for (String line : lines) {
final String[] split = line.split("\\s*=\\s*", 2);
if (split.length == 2) dlc.put(Integer.parseInt(split[0]), split[1]);
else System.err.println(MessageFormat.format("Error while splitting line: \"{0}\"", line));
}
}
// GETTERS AND SETTERS
public Integer getAppId() {
return appId;
}
public void setAppId(Integer appId) {
this.appId = appId;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public Boolean getUnlockAll() {
return unlockAll;
}
public void setUnlockAll(Boolean unlockAll) {
this.unlockAll = unlockAll;
}
public Boolean getExtraProtection() {
return extraProtection;
}
public void setExtraProtection(Boolean extraProtection) {
this.extraProtection = extraProtection;
}
public Boolean getForceOffline() {
return forceOffline;
}
public void setForceOffline(Boolean forceOffline) {
this.forceOffline = forceOffline;
}
public List<String> getLanguages() {
return languages;
}
public void setConfig(String path) throws ConfigurationException, IOException {
File file = new File(path);
if (!file.exists()) {
final boolean newFile = file.createNewFile();
}
this.config = CONFIGS.ini(path);
this.config.setCommentLeadingCharsUsedInInput(";");
this.path = path;
}
}

23
src/main/java/Main.java Normal file
View File

@ -0,0 +1,23 @@
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(ClassLoader.getSystemResource("mainWindow.fxml"));//getClass().getResource("/mainWindow.fxml")
primaryStage.setTitle("Auto CreamAPI");
primaryStage.setMinWidth(655 + 25);
primaryStage.setMinHeight(360 + 50);
primaryStage.setScene(new Scene(root, 1200, 600));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

View File

@ -0,0 +1,101 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ibasco.agql.protocols.valve.steam.webapi.SteamWebApiClient;
import com.ibasco.agql.protocols.valve.steam.webapi.interfaces.SteamApps;
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamApp;
import java.io.*;
import java.lang.reflect.Type;
import java.text.MessageFormat;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("WeakerAccess")
public class SteamAppsListCache {
static class SteamAppsList {
Instant timestamp;
List<SteamApp> steamAppsList;
}
private SteamAppsList list = new SteamAppsList();
private File cacheFile = new File("steamapps.json");
public SteamAppsListCache() {
getListFromFile();
if (Instant.now().isAfter(list.timestamp.plus(Duration.ofDays(14)))) {
getListFromApi();
saveListToFile();
}
}
public SteamApp getGame (int appId) {
for (SteamApp app : list.steamAppsList) {
if (app.getAppid() == appId) {
return app;
}
}
return null;
}
public SteamApp getGame (String name) {
for (SteamApp app : list.steamAppsList) {
if (app.getName().equalsIgnoreCase(name)) {
return app;
}
}
return null;
}
private void getListFromApi() {
SteamWebApiClient client = new SteamWebApiClient();
SteamApps steamApps = new SteamApps(client);
/*SteamStorefront storefront = new SteamStorefront(client);
StoreAppDetails appDetails = storefront.getAppDetails(440).exceptionally(throwable -> {
System.err.println(MessageFormat.format("Error Occurred: {}", throwable));
return new StoreAppDetails();
}).join();
System.out.println(appDetails);
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() {
Gson gson = new Gson();
String jsonString = gson.toJson(list);
try {
BufferedWriter fOut = new BufferedWriter(new FileWriter(cacheFile));
fOut.write(jsonString);
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void getListFromFile() {
try {
BufferedReader fIn = new BufferedReader(new FileReader(cacheFile));
StringBuilder content = new StringBuilder();
String line;
while ((line = fIn.readLine()) != null) {
content.append(line);
//content.append(System.lineSeparator());
}
String json = content.toString();
final Type type = new TypeToken<SteamAppsList>() {}.getType();
Gson gson = new Gson();
list = gson.fromJson(json, type);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1 @@
Main-Class: Main

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXCheckBox?>
<?import com.jfoenix.controls.JFXComboBox?>
<?import com.jfoenix.controls.JFXTextArea?>
<?import com.jfoenix.controls.JFXTextField?>
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane hgap="10.0" minHeight="360.0" minWidth="655.0" vgap="10.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Controller">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="-Infinity" prefWidth="375.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="120.0" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="120.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="-Infinity" prefHeight="60.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="-Infinity" minHeight="-Infinity" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
<JFXTextField fx:id="path_textfield" promptText="Path to game's steam_api(64).dll..." GridPane.columnSpan="2" />
<JFXButton fx:id="path_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#openFileChooser" GridPane.columnIndex="2">
<graphic>
<FontAwesomeIconView glyphName="FOLDER_OPEN" glyphSize="24" />
</graphic>
</JFXButton>
<JFXTextField fx:id="game_name_textfield" promptText="Game..." GridPane.rowIndex="1" />
<JFXButton fx:id="getAppId_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#getAppId" GridPane.columnIndex="1" GridPane.rowIndex="1">
<graphic>
<FontAwesomeIconView glyphName="ARROW_RIGHT" glyphSize="24" />
</graphic>
</JFXButton>
<JFXTextField fx:id="appId_textfield" prefWidth="299.0" promptText="Steam AppID..." GridPane.columnIndex="2" GridPane.rowIndex="1" />
<JFXComboBox fx:id="language_combobox" editable="true" promptText="Language" GridPane.columnSpan="2147483647" GridPane.rowIndex="2" />
<JFXCheckBox fx:id="offline_checkbox" text="Force offline mode" GridPane.columnSpan="2147483647" GridPane.rowIndex="3" />
<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" />
<JFXTextArea fx:id="dlc_textarea" promptText="List of DLC..." GridPane.columnSpan="2147483647" GridPane.rowIndex="6" />
<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" />
</GridPane>