Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
miermontoto committed Oct 20, 2022
1 parent 95a56ed commit 7b3df17
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
9 changes: 6 additions & 3 deletions src/game/LauncherRF.java
Original file line number Diff line number Diff line change
Expand Up @@ -876,12 +876,15 @@ private void jmiNuevaPartidaActionPerformed(java.awt.event.ActionEvent evt) {//G
}//GEN-LAST:event_jmiNuevaPartidaActionPerformed

private void jmiTrucosLoopSlowdownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiTrucosLoopSlowdownActionPerformed
var result = Integer.parseInt(Dialog.input("Introduzca el valor del nuevo slowdown (ms):", (x) -> (0 <= Integer.parseInt(x))));
loopComms.setSlowdown(result);
try {
loopComms.setSlowdown(Integer.parseInt(Dialog.input("Introduzca el valor del nuevo slowdown (ms):", (x) -> (0 <= Integer.parseInt(x)))));
} catch (NumberFormatException nfe) {Dialog.showError("El valor introducido no es un número.");}
}//GEN-LAST:event_jmiTrucosLoopSlowdownActionPerformed

private void jmiTrucosLoopLimitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiTrucosLoopLimitActionPerformed
loopComms.setLimit(Integer.parseInt(Dialog.input("Introduzca el límite de iteraciones:", (x) -> (Integer.parseInt(x) >= 0))));
try {
loopComms.setLimit(Integer.parseInt(Dialog.input("Introduzca el límite de iteraciones:", (x) -> (Integer.parseInt(x) >= 0))));
} catch (NumberFormatException nfe) {Dialog.showError("El valor introducido no es un número.");}
}//GEN-LAST:event_jmiTrucosLoopLimitActionPerformed

private void pneInfoComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_pneInfoComponentShown
Expand Down
26 changes: 10 additions & 16 deletions src/handler/Loader.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,21 @@
* @author Juan Mier
*/
public class Loader {

private final String title;
private final FileNameExtensionFilter fnef;

/**
* Constrctor generado para cumplir con SonarLint:S1118.
*
* @see <a href="https://sonarcloud.io/organizations/default/rules?languages=java&open=java%3AS1118&q=S1118">
* Regla SonarLint:S1118 </a>
*/
public Loader(String s, FileNameExtensionFilter f) {
title = s;
fnef = f;

public Loader(String windowTitle, FileNameExtensionFilter fnef) {
this.title = windowTitle;
this.fnef = fnef;
}

public File load() {
JFileChooser jfc = jfcGenerator();
int res = jfc.showOpenDialog(null);
return res == JFileChooser.APPROVE_OPTION ? jfc.getSelectedFile() : null;
}

private JFileChooser jfcGenerator() {
JFileChooser jfc = new JFileChooser("./");
jfc.setMultiSelectionEnabled(false);
Expand All @@ -44,19 +38,19 @@ private JFileChooser jfcGenerator() {
jfc.setFileFilter(fnef);
return jfc;
}

public String loadString() {
File f = this.load();
if(f == null) return null;
try {
return Files.readString(f.toPath());
} catch (IOException ex) {return null;}
}

public File save() {
JFileChooser jfc = jfcGenerator();
int res = jfc.showSaveDialog(null);
return res == JFileChooser.APPROVE_OPTION ? jfc.getSelectedFile() : null;
}

}
20 changes: 10 additions & 10 deletions src/obj/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@ public boolean getStatus(String settingName) {

/**
* Método que establece el valor de una opción.
* @param s Opción del que se quiere cambiar el valor.
* @param b Valor a establecer.
* @param settingName Opción del que se quiere cambiar el valor.
* @param bool Valor a establecer.
* @return Devuelve el valor booleano que devuelve {@code put} o {@code false} si la opción no existe.
*/
public boolean setStatus(String s, boolean b) {
if(!settingsMap.containsKey(s)) {
System.err.println("Opción no existente: " + s);
public boolean setStatus(String settingName, boolean bool) {
if(!settingsMap.containsKey(settingName)) {
System.err.println("Opción no existente: " + settingName);
return false;
}
return settingsMap.put(s, b);
return settingsMap.put(settingName, bool);
}

/**
* Método que conmuta el valor de una opción.
* @param s Nombre de la opción a conmutar.
* @param settingName Nombre de la opción a conmutar.
* @return Devuelve el nuevo valor booleano de la opción.
*/
public boolean toggleStatus(String s) {
public boolean toggleStatus(String settingName) {
//if(!settingsMap.containsKey(s)) throw new OperationNotSupportedException("Opción no existente.");
boolean newValue = !settingsMap.get(s);
settingsMap.put(s, newValue);
boolean newValue = !settingsMap.get(settingName);
settingsMap.put(settingName, newValue);
return newValue;
}

Expand Down

0 comments on commit 7b3df17

Please sign in to comment.