Visual indicators should work properly now
This commit is contained in:
parent
efa6fd29bc
commit
4c8400aa00
@ -23,6 +23,7 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.Tooltip;
|
import javafx.scene.control.Tooltip;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
@ -46,8 +47,10 @@ import java.util.Objects;
|
|||||||
public class Controller {
|
public class Controller {
|
||||||
|
|
||||||
private static final String REGEX = "(?<steamApiDll>steam_api(?:64)?.dll)$";
|
private static final String REGEX = "(?<steamApiDll>steam_api(?:64)?.dll)$";
|
||||||
|
public Label creamApiDllApplied;
|
||||||
|
public Label creamApiConfigExists;
|
||||||
public FontAwesomeIconView creamApiDllAppliedIcon;
|
public FontAwesomeIconView creamApiDllAppliedIcon;
|
||||||
public FontAwesomeIconView creamApiConfigExists;
|
public FontAwesomeIconView creamApiConfigExistsIcon;
|
||||||
private CreamApiDllHandler handler = null;
|
private CreamApiDllHandler handler = null;
|
||||||
private boolean is64Bit;
|
private boolean is64Bit;
|
||||||
private boolean isSameFile;
|
private boolean isSameFile;
|
||||||
@ -124,7 +127,7 @@ public class Controller {
|
|||||||
|
|
||||||
private void emptyFields() {
|
private void emptyFields() {
|
||||||
creamApiDllAppliedIcon.setGlyphName("TIMES");
|
creamApiDllAppliedIcon.setGlyphName("TIMES");
|
||||||
creamApiConfigExists.setGlyphName("TIMES");
|
creamApiConfigExistsIcon.setGlyphName("TIMES");
|
||||||
appId_textfield.setText("");
|
appId_textfield.setText("");
|
||||||
dlc_textarea.setText("");
|
dlc_textarea.setText("");
|
||||||
game_name_textfield.setText("");
|
game_name_textfield.setText("");
|
||||||
@ -170,7 +173,6 @@ public class Controller {
|
|||||||
try {
|
try {
|
||||||
config.read();
|
config.read();
|
||||||
read();
|
read();
|
||||||
updateIndicators();
|
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
state_label.setText("Successfully reset all fields!");
|
state_label.setText("Successfully reset all fields!");
|
||||||
}
|
}
|
||||||
@ -183,9 +185,12 @@ public class Controller {
|
|||||||
state_label.setText("Could not reset fields, no configuration file set!");
|
state_label.setText("Could not reset fields, no configuration file set!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateIndicators();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateIndicators() {
|
private void updateIndicators() {
|
||||||
|
Color green = Color.web("#43A047");
|
||||||
|
Color black = Color.web("#E53935");
|
||||||
try {
|
try {
|
||||||
is64Bit = false;
|
is64Bit = false;
|
||||||
if (!steamApiPathString.isEmpty()) {
|
if (!steamApiPathString.isEmpty()) {
|
||||||
@ -197,19 +202,33 @@ public class Controller {
|
|||||||
String md5 = DigestUtils.md5Hex(is);
|
String md5 = DigestUtils.md5Hex(is);
|
||||||
isSameFile = Objects.equals(md5, handler.getDllMd5(is64Bit));
|
isSameFile = Objects.equals(md5, handler.getDllMd5(is64Bit));
|
||||||
if (isSameFile) {
|
if (isSameFile) {
|
||||||
|
creamApiDllApplied.setTextFill(green);
|
||||||
|
creamApiDllAppliedIcon.setFill(green);
|
||||||
creamApiDllAppliedIcon.setGlyphName("CHECK");
|
creamApiDllAppliedIcon.setGlyphName("CHECK");
|
||||||
} else {
|
} else {
|
||||||
|
creamApiDllApplied.setTextFill(black);
|
||||||
|
creamApiDllAppliedIcon.setFill(black);
|
||||||
creamApiDllAppliedIcon.setGlyphName("TIMES");
|
creamApiDllAppliedIcon.setGlyphName("TIMES");
|
||||||
}
|
}
|
||||||
Path configPath = Paths.get(config.getPath());
|
Path configPath = Paths.get(config.getPath());
|
||||||
if (Files.exists(configPath) && Files.size(configPath) != 0L) {
|
if (Files.exists(configPath) && Files.size(configPath) > 0L) {
|
||||||
creamApiConfigExists.setGlyphName("CHECK");
|
creamApiConfigExists.setTextFill(green);
|
||||||
|
creamApiConfigExistsIcon.setFill(green);
|
||||||
|
creamApiConfigExistsIcon.setGlyphName("CHECK");
|
||||||
} else {
|
} else {
|
||||||
creamApiConfigExists.setGlyphName("TIMES");
|
creamApiConfigExists.setTextFill(black);
|
||||||
|
creamApiConfigExistsIcon.setFill(black);
|
||||||
|
creamApiConfigExistsIcon.setGlyphName("TIMES");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
System.err.println("No file found, could not update visual indicators!");
|
System.err.println("Error! Resetting visual indicators!");
|
||||||
|
creamApiDllApplied.setTextFill(black);
|
||||||
|
creamApiDllAppliedIcon.setFill(black);
|
||||||
|
creamApiDllAppliedIcon.setGlyphName("TIMES");
|
||||||
|
creamApiConfigExists.setTextFill(black);
|
||||||
|
creamApiConfigExistsIcon.setFill(black);
|
||||||
|
creamApiConfigExistsIcon.setGlyphName("TIMES");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@
|
|||||||
<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>
|
||||||
<Label maxHeight="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity"
|
<Label maxHeight="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity"
|
||||||
text="CreamAPI DLL applied">
|
text="CreamAPI DLL applied" fx:id="creamApiDllApplied">
|
||||||
<font>
|
<font>
|
||||||
<Font size="14.0"/>
|
<Font size="14.0"/>
|
||||||
</font>
|
</font>
|
||||||
@ -108,12 +108,13 @@
|
|||||||
</graphic>
|
</graphic>
|
||||||
</Label>
|
</Label>
|
||||||
<Label layoutX="20.0" layoutY="20.0" maxHeight="1.7976931348623157E308" minHeight="-Infinity"
|
<Label layoutX="20.0" layoutY="20.0" maxHeight="1.7976931348623157E308" minHeight="-Infinity"
|
||||||
minWidth="-Infinity" text="CreamAPI configuration file exists" GridPane.rowIndex="1">
|
minWidth="-Infinity" text="CreamAPI configuration file exists" GridPane.rowIndex="1"
|
||||||
|
fx:id="creamApiConfigExists">
|
||||||
<font>
|
<font>
|
||||||
<Font size="14.0"/>
|
<Font size="14.0"/>
|
||||||
</font>
|
</font>
|
||||||
<graphic>
|
<graphic>
|
||||||
<FontAwesomeIconView fx:id="creamApiConfigExists" glyphName="TIMES" size="20"/>
|
<FontAwesomeIconView fx:id="creamApiConfigExistsIcon" glyphName="TIMES" size="20"/>
|
||||||
</graphic>
|
</graphic>
|
||||||
</Label>
|
</Label>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
Loading…
Reference in New Issue
Block a user