mirror of
https://github.com/developersu/ns-usbloader.git
synced 2025-05-15 15:44:55 -04:00
Using idea from #90: Replace 'Tinfoil' by 'Awoo' everywhere on the front end. Also touched translation files (hope didn't broke it, but could be)
Add 'Fusee Geelee' and 'RCM' labels used on 'RCM' tab to 'properties' files in case someone wants to translate it.. I don't think if someone should but there is an option. (note: CLI arguments remains the same while only description updated)
This commit is contained in:
parent
86c867ab2c
commit
b02bc7ed2d
24 changed files with 164 additions and 145 deletions
|
@ -41,12 +41,14 @@ public class AppPreferences {
|
|||
theme = "/res/app_dark.css";
|
||||
return theme;
|
||||
}
|
||||
public String getProtocol(){
|
||||
String protocol = preferences.get("PROTOCOL", "TinFoil"); // Don't let user to change settings manually
|
||||
if (!protocol.matches("(^TinFoil$)|(^GoldLeaf$)"))
|
||||
protocol = "TinFoil";
|
||||
return protocol;
|
||||
public int getProtocol(){
|
||||
int protocolIndex = preferences.getInt("protocol_index", 0); // Don't let user to change settings manually
|
||||
if (protocolIndex < 0 || protocolIndex > 1)
|
||||
protocolIndex = 0;
|
||||
return protocolIndex;
|
||||
}
|
||||
public void setProtocol(int protocolIndex){ preferences.putInt("protocol_index", protocolIndex); }
|
||||
|
||||
public String getNetUsb(){
|
||||
String netUsb = preferences.get("NETUSB", "USB"); // Don't let user to change settings manually
|
||||
if (!netUsb.matches("(^USB$)|(^NET$)"))
|
||||
|
@ -55,7 +57,7 @@ public class AppPreferences {
|
|||
}
|
||||
|
||||
public void setTheme(String theme){ preferences.put("THEME", theme); }
|
||||
public void setProtocol(String protocol){ preferences.put("PROTOCOL", protocol); }
|
||||
|
||||
public void setNetUsb(String netUsb){ preferences.put("NETUSB", netUsb); }
|
||||
|
||||
public void setNsIp(String ip){preferences.put("NSIP", ip);}
|
||||
|
|
|
@ -78,13 +78,13 @@ public class GamesController implements Initializable {
|
|||
this.resourceBundle = resourceBundle;
|
||||
AppPreferences preferences = AppPreferences.getInstance();
|
||||
|
||||
ObservableList<String> choiceProtocolList = FXCollections.observableArrayList("TinFoil", "GoldLeaf");
|
||||
ObservableList<String> choiceProtocolList = FXCollections.observableArrayList("Awoo", "GoldLeaf");
|
||||
|
||||
choiceProtocol.setItems(choiceProtocolList);
|
||||
choiceProtocol.getSelectionModel().select(preferences.getProtocol());
|
||||
choiceProtocol.setOnAction(e-> {
|
||||
tableFilesListController.setNewProtocol(getSelectedProtocol());
|
||||
if (getSelectedProtocol().equals("GoldLeaf")) {
|
||||
tableFilesListController.setNewProtocol(getSelectedProtocolByName());
|
||||
if (isGoldLeaf()) {
|
||||
choiceNetUsb.setDisable(true);
|
||||
choiceNetUsb.getSelectionModel().select("USB");
|
||||
nsIpLbl.setVisible(false);
|
||||
|
@ -100,12 +100,12 @@ public class GamesController implements Initializable {
|
|||
// Really bad disable-enable upload button function
|
||||
disableUploadStopBtn(tableFilesListController.isFilesForUploadListEmpty());
|
||||
}); // Add listener to notify tableView controller
|
||||
tableFilesListController.setNewProtocol(getSelectedProtocol()); // Notify tableView controller
|
||||
tableFilesListController.setNewProtocol(getSelectedProtocolByName()); // Notify tableView controller
|
||||
|
||||
ObservableList<String> choiceNetUsbList = FXCollections.observableArrayList("USB", "NET");
|
||||
choiceNetUsb.setItems(choiceNetUsbList);
|
||||
choiceNetUsb.getSelectionModel().select(preferences.getNetUsb());
|
||||
if (getSelectedProtocol().equals("GoldLeaf")) {
|
||||
if (isGoldLeaf()) {
|
||||
choiceNetUsb.setDisable(true);
|
||||
choiceNetUsb.getSelectionModel().select("USB");
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class GamesController implements Initializable {
|
|||
});
|
||||
// Set and configure NS IP field behavior
|
||||
nsIpTextField.setText(preferences.getNsIp());
|
||||
if (getSelectedProtocol().equals("TinFoil") && getSelectedNetUsb().equals("NET")){
|
||||
if (isTinfoil() && getSelectedNetUsb().equals("NET")){
|
||||
nsIpLbl.setVisible(true);
|
||||
nsIpTextField.setVisible(true);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class GamesController implements Initializable {
|
|||
selectSplitNspBtn.getStyleClass().add("buttonSelect");
|
||||
|
||||
uploadStopBtn.setOnAction(e-> uploadBtnAction());
|
||||
uploadStopBtn.setDisable(getSelectedProtocol().equals("TinFoil"));
|
||||
uploadStopBtn.setDisable(isTinfoil());
|
||||
|
||||
this.btnUpStopImage = new Region();
|
||||
btnUpStopImage.getStyleClass().add("regionUpload");
|
||||
|
@ -174,30 +174,33 @@ public class GamesController implements Initializable {
|
|||
AppPreferences.getInstance().setTheme(styleSheets.get(0));
|
||||
}
|
||||
/**
|
||||
* Get selected protocol (GL/TF)
|
||||
* Get selected protocol index (GL/Awoo)
|
||||
* */
|
||||
String getSelectedProtocol(){
|
||||
private int getSelectedProtocolByIndex(){
|
||||
return choiceProtocol.getSelectionModel().getSelectedIndex();
|
||||
}
|
||||
private String getSelectedProtocolByName(){
|
||||
return choiceProtocol.getSelectionModel().getSelectedItem();
|
||||
}
|
||||
/**
|
||||
* Get selected protocol (USB/NET)
|
||||
* */
|
||||
String getSelectedNetUsb(){
|
||||
private String getSelectedNetUsb(){
|
||||
return choiceNetUsb.getSelectionModel().getSelectedItem();
|
||||
}
|
||||
/**
|
||||
* Get NS IP address
|
||||
* */
|
||||
String getNsIp(){
|
||||
private String getNsIp(){
|
||||
return nsIpTextField.getText();
|
||||
}
|
||||
|
||||
private boolean isGoldLeaf() {
|
||||
return getSelectedProtocol().equals("GoldLeaf");
|
||||
return getSelectedProtocolByName().equals("GoldLeaf");
|
||||
}
|
||||
|
||||
private boolean isTinfoil() {
|
||||
return getSelectedProtocol().equals("TinFoil");
|
||||
return getSelectedProtocolByName().equals("Awoo");
|
||||
}
|
||||
|
||||
private boolean isAllFiletypesAllowedForGL() {
|
||||
|
@ -290,7 +293,7 @@ public class GamesController implements Initializable {
|
|||
* @param startFolder where to start
|
||||
* @param filesRegex for filenames
|
||||
*/
|
||||
// TODO: Too sophisticated. Should be moved to simple class to keep things simplier
|
||||
// TODO: Too sophisticated. Should be moved to simple class to keep things simpler
|
||||
|
||||
private void collectFiles(List<File> storage,
|
||||
File startFolder,
|
||||
|
@ -353,7 +356,7 @@ public class GamesController implements Initializable {
|
|||
|
||||
TextArea logArea = MediatorControl.getInstance().getContoller().logArea;
|
||||
|
||||
if (getSelectedProtocol().equals("TinFoil") && tableFilesListController.getFilesForUpload() == null) {
|
||||
if (isTinfoil() && tableFilesListController.getFilesForUpload() == null) {
|
||||
logArea.setText(resourceBundle.getString("tab3_Txt_NoFolderOrFileSelected"));
|
||||
return;
|
||||
}
|
||||
|
@ -369,11 +372,11 @@ public class GamesController implements Initializable {
|
|||
|
||||
SettingsController settings = MediatorControl.getInstance().getSettingsController();
|
||||
// If USB selected
|
||||
if (getSelectedProtocol().equals("GoldLeaf") ){
|
||||
if (isGoldLeaf()){
|
||||
final SettingsBlockGoldleafController goldleafSettings = settings.getGoldleafSettings();
|
||||
usbNetCommunications = new UsbCommunications(nspToUpload, "GoldLeaf" + goldleafSettings.getGlVer(), goldleafSettings.getNSPFileFilterForGL());
|
||||
}
|
||||
else if (( getSelectedProtocol().equals("TinFoil") && getSelectedNetUsb().equals("USB") )){
|
||||
else if (( isTinfoil() && getSelectedNetUsb().equals("USB") )){
|
||||
usbNetCommunications = new UsbCommunications(nspToUpload, "TinFoil", false);
|
||||
}
|
||||
else { // NET INSTALL OVER TINFOIL
|
||||
|
@ -477,7 +480,7 @@ public class GamesController implements Initializable {
|
|||
* Crunch. This function called from NSTableViewController
|
||||
* */
|
||||
public void disableUploadStopBtn(boolean disable){
|
||||
if (getSelectedProtocol().equals("TinFoil"))
|
||||
if (isTinfoil())
|
||||
uploadStopBtn.setDisable(disable);
|
||||
else
|
||||
uploadStopBtn.setDisable(false);
|
||||
|
@ -522,7 +525,7 @@ public class GamesController implements Initializable {
|
|||
public void updatePreferencesOnExit(){
|
||||
AppPreferences preferences = AppPreferences.getInstance();
|
||||
|
||||
preferences.setProtocol(getSelectedProtocol());
|
||||
preferences.setProtocol(getSelectedProtocolByIndex());
|
||||
preferences.setRecent(getRecentPath());
|
||||
preferences.setNetUsb(getSelectedNetUsb());
|
||||
preferences.setNsIp(getNsIp());
|
||||
|
|
|
@ -136,14 +136,14 @@ public class CommandLineInterface {
|
|||
/* Tinfoil network mode options */
|
||||
final Option tinfoilNetOption = Option.builder("n")
|
||||
.longOpt("tfn")
|
||||
.desc("Install via Tinfoil/Awoo Network mode. Check '-n help' for information.")
|
||||
.desc("Install via Awoo Network mode. Check '-n help' for information.")
|
||||
.hasArgs()
|
||||
.argName("...")
|
||||
.build();
|
||||
/* Tinfoil/Awoo USB */
|
||||
final Option tinfoilOption = Option.builder("t")
|
||||
.longOpt("tinfoil")
|
||||
.desc("Install via Tinfoil/Awoo USB mode.")
|
||||
.desc("Install via Awoo USB mode.")
|
||||
.hasArgs()
|
||||
.argName("FILE...")
|
||||
.build();
|
||||
|
|
|
@ -50,7 +50,7 @@ class TinFoil extends TransferModule {
|
|||
|
||||
TinFoil(DeviceHandle handler, LinkedHashMap<String, File> nspMap, CancellableRunnable task, ILogPrinter logPrinter){
|
||||
super(handler, nspMap, task, logPrinter);
|
||||
print("============= Tinfoil =============", EMsgType.INFO);
|
||||
print("======== Awoo Installer and compatibles ========", EMsgType.INFO);
|
||||
|
||||
if (! sendListOfFiles())
|
||||
return;
|
||||
|
@ -69,25 +69,25 @@ class TinFoil extends TransferModule {
|
|||
byte[] padding = new byte[8];
|
||||
|
||||
if (writeUsb(TUL0)) {
|
||||
print("TF Send list of files: handshake [1/4]", EMsgType.FAIL);
|
||||
print("Send list of files: handshake [1/4]", EMsgType.FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (writeUsb(nspListNamesSize)) { // size of the list we can transfer
|
||||
print("TF Send list of files: list length [2/4]", EMsgType.FAIL);
|
||||
print("Send list of files: list length [2/4]", EMsgType.FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (writeUsb(padding)) {
|
||||
print("TF Send list of files: padding [3/4]", EMsgType.FAIL);
|
||||
print("Send list of files: padding [3/4]", EMsgType.FAIL);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (writeUsb(nspListNames)) {
|
||||
print("TF Send list of files: list itself [4/4]", EMsgType.FAIL);
|
||||
print("Send list of files: list itself [4/4]", EMsgType.FAIL);
|
||||
return false;
|
||||
}
|
||||
print("TF Send list of files complete.", EMsgType.PASS);
|
||||
print("Send list of files complete.", EMsgType.PASS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class TinFoil extends TransferModule {
|
|||
* After we sent commands to NS, this chain starts
|
||||
* */
|
||||
private boolean proceedCommands(){
|
||||
print("TF Awaiting for NS commands.", EMsgType.INFO);
|
||||
print("Awaiting for NS commands.", EMsgType.INFO);
|
||||
try{
|
||||
byte[] deviceReply;
|
||||
byte command;
|
||||
|
@ -127,11 +127,11 @@ class TinFoil extends TransferModule {
|
|||
|
||||
switch (command){
|
||||
case CMD_EXIT:
|
||||
print("TF Transfer complete.", EMsgType.PASS);
|
||||
print("Transfer complete.", EMsgType.PASS);
|
||||
return true;
|
||||
case CMD_FILE_RANGE_DEFAULT:
|
||||
case CMD_FILE_RANGE_ALTERNATIVE:
|
||||
//print("TF Received 'FILE RANGE' command [0x0"+command+"].", EMsgType.PASS);
|
||||
//print("Received 'FILE RANGE' command [0x0"+command+"].", EMsgType.PASS);
|
||||
if (fileRangeCmd())
|
||||
return false; // catches exception
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class TinFoil extends TransferModule {
|
|||
|
||||
String nspFileName = new String(receivedArray, StandardCharsets.UTF_8);
|
||||
|
||||
print(String.format("TF Reply to: %s" +
|
||||
print(String.format("Reply to: %s" +
|
||||
"\n Offset: %-20d 0x%x" +
|
||||
"\n Size: %-20d 0x%x",
|
||||
nspFileName,
|
||||
|
@ -188,16 +188,16 @@ class TinFoil extends TransferModule {
|
|||
else
|
||||
sendNormalFile(nspFile, size, offset);
|
||||
} catch (IOException ioe){
|
||||
print("TF IOException:\n "+ioe.getMessage(), EMsgType.FAIL);
|
||||
print("IOException:\n "+ioe.getMessage(), EMsgType.FAIL);
|
||||
ioe.printStackTrace();
|
||||
return true;
|
||||
} catch (ArithmeticException ae){
|
||||
print("TF ArithmeticException (can't cast 'offset end' - 'offsets current' to 'integer'):" +
|
||||
print("ArithmeticException (can't cast 'offset end' - 'offsets current' to 'integer'):" +
|
||||
"\n "+ae.getMessage(), EMsgType.FAIL);
|
||||
ae.printStackTrace();
|
||||
return true;
|
||||
} catch (NullPointerException npe){
|
||||
print("TF NullPointerException (in some moment application didn't find something. Something important.):" +
|
||||
print("NullPointerException (in some moment application didn't find something. Something important.):" +
|
||||
"\n "+npe.getMessage(), EMsgType.FAIL);
|
||||
npe.printStackTrace();
|
||||
return true;
|
||||
|
@ -216,7 +216,7 @@ class TinFoil extends TransferModule {
|
|||
|
||||
NSSplitReader nsSplitReader = new NSSplitReader(nspFile, size);
|
||||
if (nsSplitReader.seek(offset) != offset)
|
||||
throw new IOException("TF Requested offset is out of file size. Nothing to transmit.");
|
||||
throw new IOException("Requested offset is out of file size. Nothing to transmit.");
|
||||
|
||||
while (currentOffset < size){
|
||||
if ((currentOffset + chunk) >= size )
|
||||
|
@ -226,10 +226,10 @@ class TinFoil extends TransferModule {
|
|||
readBuffer = new byte[chunk]; // TODO: not perfect moment, consider refactoring.
|
||||
|
||||
if (nsSplitReader.read(readBuffer) != chunk)
|
||||
throw new IOException("TF Reading from stream suddenly ended.");
|
||||
throw new IOException("Reading from stream suddenly ended.");
|
||||
|
||||
if (writeUsb(readBuffer))
|
||||
throw new IOException("TF Failure during file transfer.");
|
||||
throw new IOException("Failure during file transfer.");
|
||||
currentOffset += chunk;
|
||||
logPrinter.updateProgress((double)currentOffset / (double)size);
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ class TinFoil extends TransferModule {
|
|||
BufferedInputStream bufferedInStream = new BufferedInputStream(new FileInputStream(nspFile));
|
||||
|
||||
if (bufferedInStream.skip(offset) != offset)
|
||||
throw new IOException("TF Requested offset is out of file size. Nothing to transmit.");
|
||||
throw new IOException("Requested offset is out of file size. Nothing to transmit.");
|
||||
|
||||
while (currentOffset < size) {
|
||||
if ((currentOffset + chunk) >= size)
|
||||
|
@ -255,10 +255,10 @@ class TinFoil extends TransferModule {
|
|||
readBuffer = new byte[chunk];
|
||||
|
||||
if (bufferedInStream.read(readBuffer) != chunk)
|
||||
throw new IOException("TF Reading from stream suddenly ended.");
|
||||
throw new IOException("Reading from stream suddenly ended.");
|
||||
|
||||
if (writeUsb(readBuffer))
|
||||
throw new IOException("TF Failure during file transfer.");
|
||||
throw new IOException("Failure during file transfer.");
|
||||
currentOffset += chunk;
|
||||
logPrinter.updateProgress((double)currentOffset / (double)size);
|
||||
}
|
||||
|
@ -278,17 +278,17 @@ class TinFoil extends TransferModule {
|
|||
final byte[] twelveZeroBytes = new byte[12];
|
||||
|
||||
if (writeUsb(standardReplyBytes)){ // Send integer value of '1' in Little-endian format.
|
||||
print("TF Sending response failed [1/3]", EMsgType.FAIL);
|
||||
print("Sending response failed [1/3]", EMsgType.FAIL);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(writeUsb(sizeAsBytes)) { // Send EXACTLY what has been received
|
||||
print("TF Sending response failed [2/3]", EMsgType.FAIL);
|
||||
print("Sending response failed [2/3]", EMsgType.FAIL);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(writeUsb(twelveZeroBytes)) { // kinda another one padding
|
||||
print("TF Sending response failed [3/3]", EMsgType.FAIL);
|
||||
print("Sending response failed [3/3]", EMsgType.FAIL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -317,7 +317,7 @@ class TinFoil extends TransferModule {
|
|||
case LibUsb.SUCCESS:
|
||||
if (writeBufTransferred.get() == message.length)
|
||||
return false;
|
||||
print("TF Data transfer issue [write]" +
|
||||
print("Data transfer issue [write]" +
|
||||
"\n Requested: "+message.length+
|
||||
"\n Transferred: "+writeBufTransferred.get(), EMsgType.FAIL);
|
||||
return true;
|
||||
|
@ -326,13 +326,13 @@ class TinFoil extends TransferModule {
|
|||
//writeBufTransferred.clear(); // MUST BE HERE IF WE 'GET()' IT
|
||||
continue;
|
||||
default:
|
||||
print("TF Data transfer issue [write]" +
|
||||
print("Data transfer issue [write]" +
|
||||
"\n Returned: "+ UsbErrorCodes.getErrCode(result) +
|
||||
"\n (execution stopped)", EMsgType.FAIL);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
print("TF Execution interrupted", EMsgType.INFO);
|
||||
print("Execution interrupted", EMsgType.INFO);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
|
@ -357,11 +357,11 @@ class TinFoil extends TransferModule {
|
|||
case LibUsb.ERROR_TIMEOUT:
|
||||
continue;
|
||||
default:
|
||||
throw new Exception("TF Data transfer issue [read]" +
|
||||
throw new Exception("Data transfer issue [read]" +
|
||||
"\n Returned: " + UsbErrorCodes.getErrCode(result)+
|
||||
"\n (execution stopped)");
|
||||
}
|
||||
}
|
||||
throw new InterruptedException("TF Execution interrupted");
|
||||
throw new InterruptedException("Execution interrupted");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue