v0.3 UI updates. It's nightmare..
This commit is contained in:
parent
3a238d296c
commit
5e4a93af7c
11 changed files with 160 additions and 34 deletions
|
@ -10,6 +10,33 @@ public class AppPreferences {
|
|||
|
||||
private AppPreferences(){ preferences = Preferences.userRoot().node("NS-USBloader"); }
|
||||
|
||||
public void setAll(
|
||||
String Protocol,
|
||||
String PreviouslyOpened,
|
||||
String NetUsb,
|
||||
String NsIp,
|
||||
boolean NsIpValidate,
|
||||
boolean ExpertMode,
|
||||
boolean AutoIp,
|
||||
boolean RandPort,
|
||||
boolean NotServe,
|
||||
String HostIp,
|
||||
String HostPort,
|
||||
String HostExtra
|
||||
){
|
||||
setProtocol(Protocol);
|
||||
setRecent(PreviouslyOpened);
|
||||
setNetUsb(NetUsb);
|
||||
setNsIp(NsIp);
|
||||
setNsIpValidationNeeded(NsIpValidate);
|
||||
setExpertMode(ExpertMode);
|
||||
setAutoDetectIp(AutoIp);
|
||||
setRandPort(RandPort);
|
||||
setNotServeRequests(NotServe);
|
||||
setHostIp(HostIp);
|
||||
setHostPort(HostPort);
|
||||
setHostExtra(HostExtra);
|
||||
}
|
||||
public String getTheme(){
|
||||
String theme = preferences.get("THEME", "/res/app_dark.css"); // Don't let user to change settings manually
|
||||
if (!theme.matches("(^/res/app_dark.css$)|(^/res/app_light.css$)"))
|
||||
|
@ -56,9 +83,16 @@ public class AppPreferences {
|
|||
public String getHostIp(){ return preferences.get("HOSTIP", "0.0.0.0");}
|
||||
public void setHostIp(String ip){preferences.put("HOSTIP", ip);}
|
||||
|
||||
public String getHostPort(){ return preferences.get("HOSTPORT", "6042");}
|
||||
public String getHostPort(){
|
||||
String value = preferences.get("HOSTPORT", "6042");
|
||||
if (!value.matches("^[0-9]{1,5}$"))
|
||||
return "6042";
|
||||
if ((Integer.parseInt(value) > 65535) || (Integer.parseInt(value) < 1))
|
||||
return "6042";
|
||||
return value;
|
||||
}
|
||||
public void setHostPort(String port){preferences.put("HOSTPORT", port);}
|
||||
|
||||
public String getHostPostfix(){ return preferences.get("HOSTPOSTFIX", "");}
|
||||
public void setHostPostfix(String postfix){preferences.put("HOSTPOSTFIX", postfix);}
|
||||
public String getHostExtra(){ return preferences.get("HOSTEXTRA", "");}
|
||||
public void setHostExtra(String postfix){preferences.put("HOSTEXTRA", postfix);}
|
||||
}
|
||||
|
|
|
@ -13,19 +13,16 @@ import javafx.stage.FileChooser;
|
|||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.NET.NETCommunications;
|
||||
import nsusbloader.NET.NETPacket;
|
||||
import nsusbloader.NSLMain;
|
||||
import nsusbloader.ServiceWindow;
|
||||
import nsusbloader.USB.UsbCommunications;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class NSLMainController implements Initializable {
|
||||
|
||||
|
@ -129,7 +126,12 @@ public class NSLMainController implements Initializable {
|
|||
nsIpLbl.setVisible(true);
|
||||
nsIpTextField.setVisible(true);
|
||||
}
|
||||
|
||||
nsIpTextField.setTextFormatter(new TextFormatter<>(change -> {
|
||||
if (change.getControlNewText().contains(" ") | change.getControlNewText().contains("\t"))
|
||||
return null;
|
||||
else
|
||||
return change;
|
||||
}));
|
||||
this.previouslyOpenedPath = null;
|
||||
|
||||
Region btnSwitchImage = new Region();
|
||||
|
@ -314,13 +316,20 @@ public class NSLMainController implements Initializable {
|
|||
/**
|
||||
* Save preferences before exit
|
||||
* */
|
||||
public void exit(){
|
||||
AppPreferences.getInstance().setProtocol(choiceProtocol.getSelectionModel().getSelectedItem());
|
||||
AppPreferences.getInstance().setRecent(previouslyOpenedPath);
|
||||
AppPreferences.getInstance().setNetUsb(choiceNetUsb.getSelectionModel().getSelectedItem());
|
||||
AppPreferences.getInstance().setNsIp(nsIpTextField.getText().trim());
|
||||
|
||||
AppPreferences.getInstance().setNsIpValidationNeeded(SettingsTabController.isNsIpValidate());
|
||||
AppPreferences.getInstance().setExpertMode(SettingsTabController.getExpertModeSelected());
|
||||
public void exit(){ // TODO: add method to set all in AppPreferences
|
||||
AppPreferences.getInstance().setAll(
|
||||
choiceProtocol.getSelectionModel().getSelectedItem(),
|
||||
previouslyOpenedPath,
|
||||
choiceNetUsb.getSelectionModel().getSelectedItem(),
|
||||
nsIpTextField.getText().trim(),
|
||||
SettingsTabController.isNsIpValidate(),
|
||||
SettingsTabController.getExpertModeSelected(),
|
||||
SettingsTabController.getAutoIpSelected(),
|
||||
SettingsTabController.getRandPortSelected(),
|
||||
SettingsTabController.getNotServeSelected(),
|
||||
SettingsTabController.getHostIp(),
|
||||
SettingsTabController.getHostPort(),
|
||||
SettingsTabController.getHostExtra()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,15 @@ import javafx.fxml.FXML;
|
|||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.TextFormatter;
|
||||
import javafx.scene.layout.VBox;
|
||||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.ServiceWindow;
|
||||
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
public class SettingsController implements Initializable {
|
||||
|
||||
|
@ -27,7 +30,7 @@ public class SettingsController implements Initializable {
|
|||
@FXML
|
||||
private TextField pcPortTextField;
|
||||
@FXML
|
||||
private TextField pcPostfixTextField;
|
||||
private TextField pcExtraTextField;
|
||||
|
||||
@FXML
|
||||
private CheckBox dontServeCb;
|
||||
|
@ -43,23 +46,96 @@ public class SettingsController implements Initializable {
|
|||
|
||||
expertModeCb.setSelected(AppPreferences.getInstance().getExpertMode());
|
||||
expertModeCb.setOnAction(e->{
|
||||
if (expertModeCb.isSelected())
|
||||
expertSettingsVBox.setDisable(false);
|
||||
else
|
||||
expertSettingsVBox.setDisable(true);
|
||||
expertSettingsVBox.setDisable(!expertModeCb.isSelected());
|
||||
});
|
||||
|
||||
autoDetectIpCb.setSelected(AppPreferences.getInstance().getAutoDetectIp());
|
||||
pcIpTextField.setDisable(AppPreferences.getInstance().getAutoDetectIp());
|
||||
autoDetectIpCb.setOnAction(e->{
|
||||
pcIpTextField.setDisable(autoDetectIpCb.isSelected());
|
||||
});
|
||||
|
||||
randPortCb.setSelected(AppPreferences.getInstance().getRandPort());
|
||||
pcPortTextField.setDisable(AppPreferences.getInstance().getRandPort());
|
||||
randPortCb.setOnAction(e->{
|
||||
pcPortTextField.setDisable(randPortCb.isSelected());
|
||||
});
|
||||
|
||||
if (AppPreferences.getInstance().getNotServeRequests()){
|
||||
dontServeCb.setSelected(true);
|
||||
|
||||
autoDetectIpCb.setSelected(false);
|
||||
autoDetectIpCb.setDisable(true);
|
||||
pcIpTextField.setDisable(false);
|
||||
|
||||
dontServeCb.setSelected(AppPreferences.getInstance().getNotServeRequests());
|
||||
randPortCb.setSelected(false);
|
||||
randPortCb.setDisable(true);
|
||||
pcPortTextField.setDisable(false);
|
||||
}
|
||||
pcExtraTextField.setDisable(!AppPreferences.getInstance().getNotServeRequests());
|
||||
|
||||
dontServeCb.setOnAction(e->{
|
||||
if (dontServeCb.isSelected()){
|
||||
autoDetectIpCb.setSelected(false);
|
||||
autoDetectIpCb.setDisable(true);
|
||||
pcIpTextField.setDisable(false);
|
||||
|
||||
randPortCb.setSelected(false);
|
||||
randPortCb.setDisable(true);
|
||||
pcPortTextField.setDisable(false);
|
||||
|
||||
pcExtraTextField.setDisable(false);
|
||||
}
|
||||
else {
|
||||
autoDetectIpCb.setDisable(false);
|
||||
autoDetectIpCb.setSelected(true);
|
||||
pcIpTextField.setDisable(true);
|
||||
|
||||
randPortCb.setDisable(false);
|
||||
randPortCb.setSelected(true);
|
||||
pcPortTextField.setDisable(true);
|
||||
|
||||
pcExtraTextField.setDisable(true);
|
||||
}
|
||||
});
|
||||
|
||||
pcIpTextField.setText(AppPreferences.getInstance().getHostIp());
|
||||
pcPortTextField.setText(AppPreferences.getInstance().getHostPort());
|
||||
pcExtraTextField.setText(AppPreferences.getInstance().getHostExtra());
|
||||
|
||||
pcIpTextField.setTextFormatter(new TextFormatter<>(change -> {
|
||||
if (change.getControlNewText().contains(" ") | change.getControlNewText().contains("\t"))
|
||||
return null;
|
||||
else
|
||||
return change;
|
||||
}));
|
||||
pcPortTextField.setTextFormatter(new TextFormatter<Object>(change -> {
|
||||
if (change.getControlNewText().matches("^[0-9]{0,5}$")) {
|
||||
if ((Integer.parseInt(change.getControlNewText()) > 65535) || (Integer.parseInt(change.getControlNewText()) == 0)) {
|
||||
ServiceWindow.getErrorNotification(resourceBundle.getString("windowTitleErrorPort"), resourceBundle.getString("windowBodyErrorPort"));
|
||||
return null;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}));
|
||||
pcExtraTextField.setTextFormatter(new TextFormatter<>(change -> {
|
||||
if (change.getControlNewText().contains(" ") | change.getControlNewText().contains("\t"))
|
||||
return null;
|
||||
else
|
||||
return change;
|
||||
}));
|
||||
}
|
||||
|
||||
public boolean getExpertModeSelected(){
|
||||
return expertModeCb.isSelected();
|
||||
}
|
||||
public boolean getExpertModeSelected(){ return expertModeCb.isSelected(); }
|
||||
public boolean getAutoIpSelected(){ return autoDetectIpCb.isSelected(); }
|
||||
public boolean getRandPortSelected(){ return randPortCb.isSelected(); }
|
||||
public boolean getNotServeSelected(){ return dontServeCb.isSelected(); }
|
||||
|
||||
public boolean isNsIpValidate(){ return validateNSHostNameCb.isSelected(); }
|
||||
}
|
||||
|
||||
public String getHostIp(){ return pcIpTextField.getText(); }
|
||||
public String getHostPort(){ return pcPortTextField.getText(); }
|
||||
public String getHostExtra(){ return pcExtraTextField.getText(); }
|
||||
}
|
|
@ -10,7 +10,6 @@ public class ServiceWindow {
|
|||
/**
|
||||
* Create window with notification
|
||||
* */
|
||||
/* // not used
|
||||
public static void getErrorNotification(String title, String body){
|
||||
Alert alertBox = new Alert(Alert.AlertType.ERROR);
|
||||
alertBox.setTitle(title);
|
||||
|
@ -20,10 +19,9 @@ public class ServiceWindow {
|
|||
alertBox.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
|
||||
alertBox.setResizable(true); // Java bug workaround for JDR11/OpenJFX. TODO: nothing. really.
|
||||
alertBox.setResizable(false);
|
||||
alertBox.getDialogPane().getStylesheets().add("/res/app.css");
|
||||
alertBox.getDialogPane().getStylesheets().add(AppPreferences.getInstance().getTheme());
|
||||
alertBox.show();
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Create notification window with confirm/deny
|
||||
* */
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<ChoiceBox fx:id="choiceProtocol" prefWidth="120.0" />
|
||||
<ChoiceBox fx:id="choiceNetUsb" prefWidth="75.0" />
|
||||
<Label fx:id="nsIpLbl" text="%NSIPlable" visible="false" />
|
||||
<TextField fx:id="nsIpTextField" prefWidth="120.0" visible="false" />
|
||||
<TextField fx:id="nsIpTextField" prefWidth="120.0" promptText="XXX,XXX,XXX,XXX" visible="false" />
|
||||
<Pane HBox.hgrow="ALWAYS" />
|
||||
<Button fx:id="switchThemeBtn" mnemonicParsing="false" />
|
||||
</items>
|
||||
|
|
|
@ -42,11 +42,11 @@
|
|||
</HBox>
|
||||
<HBox>
|
||||
<children>
|
||||
<TextField fx:id="pcIpTextField" />
|
||||
<TextField fx:id="pcIpTextField" promptText="XXX,XXX,XXX,XXX" />
|
||||
<Label text=":" />
|
||||
<TextField fx:id="pcPortTextField" />
|
||||
<TextField fx:id="pcPortTextField" promptText="0-65535" />
|
||||
<Label text="/" />
|
||||
<TextField fx:id="pcPostfixTextField">
|
||||
<TextField fx:id="pcExtraTextField" HBox.hgrow="ALWAYS">
|
||||
<HBox.margin>
|
||||
<Insets />
|
||||
</HBox.margin>
|
||||
|
|
|
@ -35,3 +35,5 @@ netTabRandSelectPortCb=Randomly get port
|
|||
netTabDontServeRequestsCb=Don't serve requests
|
||||
netTabDontServeRequestsDescription=If selected, this computer won't reply to NSP files requests coming from NS (over the net) and use defined host settings to tell TinFoil where should it look for files.
|
||||
netTabHostExtraLbl=extra
|
||||
windowTitleErrorPort=Port set incorrectly!
|
||||
windowBodyErrorPort=Port can't be 0 or greater then 65535.
|
||||
|
|
|
@ -34,4 +34,6 @@ netTabRandSelectPortCb=Randomly get port <- FIX
|
|||
netTabDontServeRequestsCb=Don't serve requests <- FIX
|
||||
netTabDontServeRequestsDescription=If selected, this computer won't reply to NSP files requests coming from NS (over the net) and use defined host settings to tell TinFoil where should it look for files. <- Fix
|
||||
netTabHostExtraLbl=extra <- FIX
|
||||
windowTitleErrorPort=Port set incorrectly! <- FIX
|
||||
windowBodyErrorPort=Port can't be 0 or greater then 65535. <- FIX
|
||||
|
||||
|
|
|
@ -36,4 +36,6 @@ netTabRandSelectPortCb=\u041E\u043F\u0440\u0435\u0434\u0435\u043B\u044F\u0442\u0
|
|||
netTabDontServeRequestsCb=\u041D\u0435 \u043E\u0431\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0442\u044C \u0437\u0430\u043F\u0440\u043E\u0441\u044B
|
||||
netTabDontServeRequestsDescription=\u0415\u0441\u043B\u0438 \u0432\u044B\u0431\u0440\u0430\u043D\u043E, \u0442\u043E\u0433\u0434\u0430 \u044D\u0442\u043E\u0442 \u043A\u043E\u043C\u043F\u044C\u044E\u0442\u0435\u0440 \u043D\u0435 \u0431\u0443\u0434\u0435\u0442 \u043E\u0442\u0432\u0435\u0447\u0430\u0442\u044C \u043D\u0430 \u0437\u0430\u043F\u0440\u043E\u0441\u044B NSP \u0444\u0430\u0439\u043B\u043E\u0432. \u0411\u0443\u0434\u0443\u0442 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0445\u043E\u0441\u0442\u0430 \u0447\u0442\u043E\u0431\u044B \u0443\u043A\u0430\u0437\u0430\u0442\u044C TinFoil \u043E\u0442\u043A\u0443\u0434\u0430 \u0435\u043C\u0443 \u0441\u043B\u0435\u0434\u0443\u0435\u0442 \u0431\u0440\u0430\u0442\u044C \u0444\u0430\u0439\u043B\u044B.
|
||||
netTabHostExtraLbl=\u044D\u043A\u0441\u0442\u0440\u0430
|
||||
windowTitleErrorPort=\u041F\u043E\u0440\u0442 \u0443\u043A\u0430\u0437\u0430\u043D \u043D\u0435\u0432\u0435\u0440\u043D\u043E!
|
||||
windowBodyErrorPort=\u041F\u043E\u0440\u0442 \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C 0 \u0438\u043B\u0438 \u043F\u0440\u0435\u0432\u044B\u0448\u0430\u0442\u044C 65535.
|
||||
|
||||
|
|
|
@ -34,4 +34,6 @@ netTabAutoDetectIpCb=\u0410\u0432\u0442\u043E\u043C\u0430\u0442\u0438\u0447\u043
|
|||
netTabRandSelectPortCb=\u0412\u0438\u0437\u043D\u0430\u0447\u0430\u0442\u0438 \u043F\u043E\u0440\u0442 \u0432\u0438\u043F\u0430\u0434\u043A\u043E\u0432\u0438\u043C \u0447\u0438\u043D\u043E\u043C
|
||||
netTabDontServeRequestsCb=\u041D\u0435 \u043E\u0431\u0440\u043E\u0431\u043B\u044F\u0442\u0438 \u0437\u0430\u043F\u0438\u0442\u0438
|
||||
netTabDontServeRequestsDescription=\u042F\u043A\u0449\u043E \u0432\u0438\u0431\u0440\u0430\u043D\u043E, \u0442\u043E\u0434\u0456 \u0446\u0435\u0439 \u043A\u043E\u043C\u043F'\u044E\u0442\u0435\u0440 \u043D\u0435 \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438\u043C\u0435 \u043D\u0430 \u0437\u0430\u043F\u0438\u0442\u0438 NSP \u0444\u0430\u0439\u043B\u0456\u0432. \u0412\u0438\u043A\u043E\u0440\u0438\u0441\u0442\u043E\u0432\u0443\u0432\u0430\u0442\u0438\u043C\u0443\u0442\u044C\u0441\u044F \u043D\u0430\u043B\u0430\u0448\u0442\u0443\u0432\u0430\u043D\u043D\u044F \u0445\u043E\u0441\u0442\u0430 \u0434\u043B\u044F \u0432\u043A\u0430\u0437\u0430\u043D\u043D\u044F TinFoil \u043C\u0456\u0441\u0446\u044F \u0437\u0432\u0456\u0434\u043A\u0438 \u0444\u0430\u0439\u043B\u0438 \u043C\u0430\u044E\u0442\u044C \u0431\u0440\u0430\u0442\u0438\u0441\u044F.
|
||||
netTabHostExtraLbl=\u0435\u043A\u0441\u0442\u0440\u0430
|
||||
netTabHostExtraLbl=\u0435\u043A\u0441\u0442\u0440\u0430
|
||||
windowTitleErrorPort=\u041D\u0435\u0432\u0456\u0440\u043D\u043E \u0432\u0438\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0439 \u043F\u043E\u0440\u0442!
|
||||
windowBodyErrorPort=\u041F\u043E\u0440\u0442 \u043D\u0435 \u043C\u043E\u0436\u0435 \u0431\u0443\u0442\u0438 0 \u0430\u0431\u043E \u043F\u0440\u0438\u0432\u0438\u0449\u0443\u0432\u0430\u0442\u0438 65535.
|
|
@ -232,6 +232,7 @@
|
|||
}
|
||||
// -========================== Text Field =====================-
|
||||
.text-field {
|
||||
-fx-prompt-text-fill: #40596c;
|
||||
-fx-border-color: #289de8;
|
||||
-fx-border-width: 0 0 1 0;
|
||||
-fx-background-color: transparent;
|
||||
|
|
Loading…
Reference in a new issue