Add listener to appid textfield
Added "Get DLCs for AppID" button (inactive)
This commit is contained in:
parent
aa057fca91
commit
0eedf452d7
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -1,19 +1,18 @@
|
|||||||
import com.ibasco.agql.protocols.valve.steam.webapi.pojos.SteamApp;
|
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.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
|
||||||
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 javax.swing.*;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Controller {
|
public class Controller {
|
||||||
public JFXButton path_button;
|
|
||||||
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 public JFXTextField path_textfield;
|
||||||
@ -27,14 +26,18 @@ public class Controller {
|
|||||||
@FXML public JFXButton reset_button;
|
@FXML public JFXButton reset_button;
|
||||||
@FXML public JFXButton save_button;
|
@FXML public JFXButton save_button;
|
||||||
@FXML public JFXButton getAppId_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() {
|
||||||
read();
|
appId_textfield.textProperty().addListener(appIdChangesGameName());
|
||||||
|
retrieveDlcList_button.setDisable(true); // WIP
|
||||||
generate_tooltips();
|
generate_tooltips();
|
||||||
fix_dlc_textarea_prompt_text();
|
fix_dlc_textarea_prompt_text();
|
||||||
|
read();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void read() {
|
private void read() {
|
||||||
@ -59,6 +62,23 @@ public class Controller {
|
|||||||
Tooltip.install(extra_protection_checkbox, extra_protection_tooltip);
|
Tooltip.install(extra_protection_checkbox, extra_protection_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ChangeListener<String> 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() {
|
public void reset() {
|
||||||
config.read();
|
config.read();
|
||||||
read();
|
read();
|
||||||
@ -79,7 +99,7 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getAppId() {
|
public void getAppId() {
|
||||||
final SteamApp game = cache.getGame(game_name_textfield.getText());
|
final SteamApp game = cache.searchGame(game_name_textfield.getText());
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
appId_textfield.setText("-1");
|
appId_textfield.setText("-1");
|
||||||
} else {
|
} else {
|
||||||
|
@ -49,6 +49,15 @@ public class SteamAppsListCache {
|
|||||||
return null;
|
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() {
|
private void getListFromApi() {
|
||||||
SteamWebApiClient client = new SteamWebApiClient();
|
SteamWebApiClient client = new SteamWebApiClient();
|
||||||
SteamApps steamApps = new SteamApps(client);
|
SteamApps steamApps = new SteamApps(client);
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<JFXTextField fx:id="game_name_textfield" promptText="Game..." GridPane.rowIndex="1" />
|
<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">
|
<JFXButton fx:id="getAppId_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#getAppId" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||||
<graphic>
|
<graphic>
|
||||||
<FontAwesomeIconView glyphName="ARROW_RIGHT" glyphSize="24" />
|
<FontAwesomeIconView glyphName="SEARCH" glyphSize="24" />
|
||||||
</graphic>
|
</graphic>
|
||||||
</JFXButton>
|
</JFXButton>
|
||||||
<JFXTextField fx:id="appId_textfield" prefWidth="299.0" promptText="Steam AppID..." GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
<JFXTextField fx:id="appId_textfield" prefWidth="299.0" promptText="Steam AppID..." GridPane.columnIndex="2" GridPane.rowIndex="1" />
|
||||||
@ -48,6 +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="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