save and getdlclist functions as services
added state label at bottom ripple fill color are consistent now
This commit is contained in:
parent
c5ddd55fec
commit
d33c14bab8
@ -1,7 +1,10 @@
|
|||||||
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.concurrent.Service;
|
||||||
|
import javafx.concurrent.Task;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.Tooltip;
|
import javafx.scene.control.Tooltip;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
@ -35,6 +38,8 @@ public class Controller {
|
|||||||
private CreamApiConfig config = CreamApiConfig.getInstance();
|
private CreamApiConfig config = CreamApiConfig.getInstance();
|
||||||
private SteamAppsListCache cache = new SteamAppsListCache();
|
private SteamAppsListCache cache = new SteamAppsListCache();
|
||||||
@FXML
|
@FXML
|
||||||
|
public Label state_label;
|
||||||
|
@FXML
|
||||||
public JFXTextField path_textfield;
|
public JFXTextField path_textfield;
|
||||||
@FXML
|
@FXML
|
||||||
public JFXTextField appId_textfield;
|
public JFXTextField appId_textfield;
|
||||||
@ -127,6 +132,12 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
Service<Void> s = new Service<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Task<Void> createTask() {
|
||||||
|
return new Task<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void call() {
|
||||||
try {
|
try {
|
||||||
setUpCreamApi();
|
setUpCreamApi();
|
||||||
config.setDlcListFromString(dlc_textarea.getText());
|
config.setDlcListFromString(dlc_textarea.getText());
|
||||||
@ -141,6 +152,20 @@ public class Controller {
|
|||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
System.err.println("No configuration file set!");
|
System.err.println("No configuration file set!");
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
s.setOnRunning(event -> {
|
||||||
|
setDisableAllButtons(true);
|
||||||
|
state_label.setText("Saving...");
|
||||||
|
});
|
||||||
|
s.setOnSucceeded(event -> {
|
||||||
|
setDisableAllButtons(false);
|
||||||
|
state_label.setText("Saved successfully!");
|
||||||
|
});
|
||||||
|
s.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAppId() {
|
public void getAppId() {
|
||||||
@ -162,6 +187,12 @@ public class Controller {
|
|||||||
* also lists DLC not available for purchase.
|
* also lists DLC not available for purchase.
|
||||||
*/
|
*/
|
||||||
public void getDlcList() {
|
public void getDlcList() {
|
||||||
|
Service<Void> s = new Service<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Task<Void> createTask() {
|
||||||
|
return new Task<Void>() {
|
||||||
|
@Override
|
||||||
|
protected Void call() {
|
||||||
Map<Integer, String> steamStoreDLCs = new HashMap<>();
|
Map<Integer, String> steamStoreDLCs = new HashMap<>();
|
||||||
Map<Integer, String> steamDbDLCs = new HashMap<>();
|
Map<Integer, String> steamDbDLCs = new HashMap<>();
|
||||||
//StringBuilder sb = new StringBuilder();
|
//StringBuilder sb = new StringBuilder();
|
||||||
@ -212,6 +243,20 @@ public class Controller {
|
|||||||
(oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
(oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
||||||
collect.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n"));
|
collect.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n"));
|
||||||
dlc_textarea.setText(sb.toString());
|
dlc_textarea.setText(sb.toString());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
s.setOnRunning(event -> {
|
||||||
|
setDisableAllButtons(true);
|
||||||
|
state_label.setText("Getting list of DLCs...");
|
||||||
|
});
|
||||||
|
s.setOnSucceeded(event -> {
|
||||||
|
setDisableAllButtons(false);
|
||||||
|
state_label.setText("Got list of DLCs successfully!");
|
||||||
|
});
|
||||||
|
s.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openFileChooser() {
|
public void openFileChooser() {
|
||||||
@ -262,4 +307,12 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDisableAllButtons(boolean b) {
|
||||||
|
reset_button.setDisable(b);
|
||||||
|
save_button.setDisable(b);
|
||||||
|
getAppId_button.setDisable(b);
|
||||||
|
path_button.setDisable(b);
|
||||||
|
retrieveDlcList_button.setDisable(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class Main extends Application {
|
|||||||
Parent root = FXMLLoader.load(ClassLoader.getSystemResource("mainWindow.fxml"));//getClass().getResource("/mainWindow.fxml")
|
Parent root = FXMLLoader.load(ClassLoader.getSystemResource("mainWindow.fxml"));//getClass().getResource("/mainWindow.fxml")
|
||||||
primaryStage.setTitle("Auto CreamAPI");
|
primaryStage.setTitle("Auto CreamAPI");
|
||||||
primaryStage.setMinWidth(655 + 25);
|
primaryStage.setMinWidth(655 + 25);
|
||||||
primaryStage.setMinHeight(360 + 50);
|
primaryStage.setMinHeight(400 + 50);
|
||||||
primaryStage.setScene(new Scene(root, 1200, 600));
|
primaryStage.setScene(new Scene(root, 1200, 600));
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,12 @@
|
|||||||
<?import com.jfoenix.controls.JFXTextField?>
|
<?import com.jfoenix.controls.JFXTextField?>
|
||||||
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
|
<?import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView?>
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?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">
|
<GridPane hgap="10.0" minHeight="400.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>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="1.7976931348623157E308" minWidth="-Infinity" prefWidth="375.0" />
|
<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" />
|
||||||
@ -26,18 +27,19 @@
|
|||||||
<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 minHeight="-Infinity" prefHeight="60.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="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
</rowConstraints>
|
</rowConstraints>
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||||
</padding>
|
</padding>
|
||||||
<JFXTextField fx:id="path_textfield" promptText="Path to game's steam_api(64).dll..." GridPane.columnSpan="2" />
|
<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">
|
<JFXButton fx:id="path_button" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" onAction="#openFileChooser" ripplerFill="BLACK" style="-fx-background-color: #ddd;" GridPane.columnIndex="2">
|
||||||
<graphic>
|
<graphic>
|
||||||
<FontAwesomeIconView glyphName="FOLDER_OPEN" glyphSize="24" />
|
<FontAwesomeIconView glyphName="FOLDER_OPEN" glyphSize="24" />
|
||||||
</graphic>
|
</graphic>
|
||||||
</JFXButton>
|
</JFXButton>
|
||||||
<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" ripplerFill="BLACK" style="-fx-background-color: #ddd;" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||||
<graphic>
|
<graphic>
|
||||||
<FontAwesomeIconView glyphName="SEARCH" glyphSize="24" />
|
<FontAwesomeIconView glyphName="SEARCH" glyphSize="24" />
|
||||||
</graphic>
|
</graphic>
|
||||||
@ -48,7 +50,8 @@
|
|||||||
<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" onAction="#getDlcList" text="Get DLCs for AppID" GridPane.rowIndex="7" />
|
<JFXButton fx:id="retrieveDlcList_button" maxHeight="1.7976931348623157E308" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onAction="#getDlcList" ripplerFill="BLACK" style="-fx-background-color: #ddd;" 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" ripplerFill="BLACK" style="-fx-background-color: #ddd;" 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" ripplerFill="BLACK" style="-fx-background-color: #ddd;" text="Reset" GridPane.columnIndex="2" GridPane.rowIndex="7" />
|
||||||
|
<Label fx:id="state_label" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" GridPane.columnSpan="2147483647" GridPane.rowIndex="8" />
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
Loading…
Reference in New Issue
Block a user