Visual indicators are now functional
This commit is contained in:
parent
000133bb87
commit
622046120a
@ -40,6 +40,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Controller {
|
public class Controller {
|
||||||
@ -118,6 +119,18 @@ public class Controller {
|
|||||||
unlockAll_disableDlcTextArea();
|
unlockAll_disableDlcTextArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void emptyFields() {
|
||||||
|
creamApiDllAppliedIcon.setGlyphName("TIMES");
|
||||||
|
creamApiConfigExists.setGlyphName("TIMES");
|
||||||
|
appId_textfield.setText("");
|
||||||
|
dlc_textarea.setText("");
|
||||||
|
game_name_textfield.setText("");
|
||||||
|
extra_protection_checkbox.setSelected(false);
|
||||||
|
offline_checkbox.setSelected(false);
|
||||||
|
unlock_all_checkbox.setSelected(false);
|
||||||
|
unlockAll_disableDlcTextArea();
|
||||||
|
}
|
||||||
|
|
||||||
private void fix_dlc_textarea_prompt_text() {
|
private void fix_dlc_textarea_prompt_text() {
|
||||||
dlc_textarea.setPromptText("List of DLC...\r0000 = DLC Name");
|
dlc_textarea.setPromptText("List of DLC...\r0000 = DLC Name");
|
||||||
}
|
}
|
||||||
@ -154,9 +167,13 @@ 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!");
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
System.err.println("Error reading cream_api.ini! " +
|
||||||
|
"This can be ignored if setting up CreamAPI for the first time.");
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
System.err.println("Can't fill out fields, no configuration file set!");
|
System.err.println("Can't fill out fields, no configuration file set!");
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
@ -165,6 +182,34 @@ public class Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateIndicators() {
|
||||||
|
try {
|
||||||
|
boolean is64Bit = false;
|
||||||
|
if (!steamApiPathString.isEmpty()) {
|
||||||
|
Path dllPath = Paths.get(steamApiPathString);
|
||||||
|
if (dllPath.endsWith("steam_api64.dll")) {
|
||||||
|
is64Bit = true;
|
||||||
|
}
|
||||||
|
InputStream is = Files.newInputStream(dllPath);
|
||||||
|
String md5 = DigestUtils.md5Hex(is);
|
||||||
|
boolean isSameFile = Objects.equals(md5, handler.getDllMd5(is64Bit));
|
||||||
|
if (isSameFile) {
|
||||||
|
creamApiDllAppliedIcon.setGlyphName("CHECK");
|
||||||
|
} else {
|
||||||
|
creamApiDllAppliedIcon.setGlyphName("TIMES");
|
||||||
|
}
|
||||||
|
Path configPath = Paths.get(config.getPath());
|
||||||
|
if (Files.exists(configPath) && Files.size(configPath) != 0L) {
|
||||||
|
creamApiConfigExists.setGlyphName("CHECK");
|
||||||
|
} else {
|
||||||
|
creamApiConfigExists.setGlyphName("TIMES");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("No file found, could not update visual indicators!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
Service<Void> s = new Service<Void>() {
|
Service<Void> s = new Service<Void>() {
|
||||||
@Override
|
@Override
|
||||||
@ -280,15 +325,16 @@ public class Controller {
|
|||||||
final File file = chooser.showOpenDialog(path_button.getScene().getWindow());
|
final File file = chooser.showOpenDialog(path_button.getScene().getWindow());
|
||||||
try {
|
try {
|
||||||
config.setConfig(file.getParent() + "\\cream_api.ini");
|
config.setConfig(file.getParent() + "\\cream_api.ini");
|
||||||
path_textfield.setText(file.getParent());
|
|
||||||
steamApiPathString = file.getAbsolutePath();
|
|
||||||
reset(true);
|
|
||||||
state_label.setText("Ready.");
|
|
||||||
} catch (ConfigurationException | IOException e) {
|
} catch (ConfigurationException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
System.err.println("Could not set config file location! Did you cancel the file chooser?");
|
System.err.println("Could not set config file location! Did you cancel the file chooser?");
|
||||||
}
|
}
|
||||||
|
path_textfield.setText(file.getParent());
|
||||||
|
steamApiPathString = file.getAbsolutePath();
|
||||||
|
emptyFields();
|
||||||
|
reset(true);
|
||||||
|
state_label.setText("Ready.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,11 @@ public class CreamApiConfig {
|
|||||||
private static final Configurations CONFIGS = new Configurations();
|
private static final Configurations CONFIGS = new Configurations();
|
||||||
|
|
||||||
private INIConfiguration config;
|
private INIConfiguration config;
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
private String path = "cream_api.ini";
|
private String path = "cream_api.ini";
|
||||||
private Integer appId;
|
private Integer appId;
|
||||||
private String language;
|
private String language;
|
||||||
@ -57,6 +62,9 @@ public class CreamApiConfig {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
read();
|
read();
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
System.err.println("Error reading cream_api.ini! " +
|
||||||
|
"This can be ignored if setting up CreamAPI for the first time.");
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
System.err.println("Can't fill out fields, no configuration file set!");
|
System.err.println("Can't fill out fields, no configuration file set!");
|
||||||
}
|
}
|
||||||
@ -69,8 +77,7 @@ public class CreamApiConfig {
|
|||||||
return configInstance;
|
return configInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read() throws NullPointerException {
|
public void read() throws NullPointerException, NoSuchElementException {
|
||||||
try {
|
|
||||||
appId = config.getInt("steam.appid");
|
appId = config.getInt("steam.appid");
|
||||||
language = config.getString("steam.language");
|
language = config.getString("steam.language");
|
||||||
if (language == null) {
|
if (language == null) {
|
||||||
@ -81,10 +88,6 @@ public class CreamApiConfig {
|
|||||||
forceOffline = config.getBoolean("steam.forceoffline");
|
forceOffline = config.getBoolean("steam.forceoffline");
|
||||||
final SubnodeConfiguration dlc_section = config.getSection("dlc");
|
final SubnodeConfiguration dlc_section = config.getSection("dlc");
|
||||||
dlc_section.getKeys().forEachRemaining(k -> dlc.put(Integer.parseInt(k), dlc_section.getString(k)));
|
dlc_section.getKeys().forEachRemaining(k -> dlc.put(Integer.parseInt(k), dlc_section.getString(k)));
|
||||||
} catch (NoSuchElementException e) {
|
|
||||||
System.err.println("Error reading cream_api.ini! " +
|
|
||||||
"This can be ignored if setting up CreamAPI for the first time.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sync() throws ConfigurationException {
|
public void sync() throws ConfigurationException {
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
<Font size="14.0"/>
|
<Font size="14.0"/>
|
||||||
</font>
|
</font>
|
||||||
<graphic>
|
<graphic>
|
||||||
<FontAwesomeIconView fx:id="creamApiDllAppliedIcon" glyphName="CIRCLE" size="20"/>
|
<FontAwesomeIconView fx:id="creamApiDllAppliedIcon" glyphName="TIMES" size="20"/>
|
||||||
</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"
|
||||||
@ -113,7 +113,7 @@
|
|||||||
<Font size="14.0"/>
|
<Font size="14.0"/>
|
||||||
</font>
|
</font>
|
||||||
<graphic>
|
<graphic>
|
||||||
<FontAwesomeIconView fx:id="creamApiConfigExists" glyphName="CIRCLE" size="20"/>
|
<FontAwesomeIconView fx:id="creamApiConfigExists" glyphName="TIMES" size="20"/>
|
||||||
</graphic>
|
</graphic>
|
||||||
</Label>
|
</Label>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
Loading…
Reference in New Issue
Block a user