mirror of https://github.com/rusefi/RomRaider.git
Shortcut scaling validation
This commit is contained in:
parent
4e184df596
commit
ef02c63032
|
@ -85,6 +85,7 @@ public class Rom extends DefaultMutableTreeNode implements Serializable {
|
|||
// Add nodes to ROM tree.
|
||||
for (TableTreeNode tableTreeNode : tableNodes) {
|
||||
Table table = tableTreeNode.getTable();
|
||||
|
||||
String[] categories = table.getCategory().split("//");
|
||||
|
||||
if (settings.isDisplayHighTables() || settings.getUserLevel() >= table.getUserLevel()) {
|
||||
|
|
|
@ -55,6 +55,8 @@ public class Scale implements Serializable {
|
|||
}
|
||||
|
||||
public boolean validate() {
|
||||
if(expression.equals("x") && byteExpression.equals("x")) return true;
|
||||
|
||||
double startValue = 5;
|
||||
double toReal = JEPUtil.evaluate(getExpression(), startValue); // convert real world value of "5"
|
||||
double endValue = JEPUtil.evaluate(getByteExpression(), toReal);
|
||||
|
|
|
@ -118,7 +118,9 @@ public abstract class Table implements Serializable {
|
|||
}
|
||||
|
||||
public void populateTable(byte[] input, int romRamOffset) throws ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
|
||||
// temporarily remove lock;
|
||||
validateScaling();
|
||||
|
||||
// temporarily remove lock;
|
||||
boolean tempLock = locked;
|
||||
locked = false;
|
||||
|
||||
|
@ -199,8 +201,6 @@ public abstract class Table implements Serializable {
|
|||
if(SettingsManager.getSettings().getDefaultScale().equalsIgnoreCase(scale.getName())) {
|
||||
this.curScale = scale;
|
||||
}
|
||||
|
||||
validateScaling();
|
||||
}
|
||||
|
||||
public int getStorageAddress() {
|
||||
|
@ -580,13 +580,7 @@ public abstract class Table implements Serializable {
|
|||
}
|
||||
|
||||
public void validateScaling() {
|
||||
if (getType() != TableType.SWITCH) {
|
||||
|
||||
// make sure a scale is present
|
||||
if (scales.isEmpty()) {
|
||||
scales.add(new Scale());
|
||||
}
|
||||
|
||||
if (getType() != TableType.SWITCH) {
|
||||
for(Scale scale : scales) {
|
||||
if (!scale.validate()) {
|
||||
TableView.showBadScalePopup(this, scale);
|
||||
|
|
|
@ -135,6 +135,8 @@ public class Table3D extends Table {
|
|||
|
||||
@Override
|
||||
public void populateTable(byte[] input, int romRamOffset) throws NullPointerException, ArrayIndexOutOfBoundsException, IndexOutOfBoundsException {
|
||||
validateScaling();
|
||||
|
||||
// fill first empty cell
|
||||
if (!beforeRam) {
|
||||
this.ramOffset = romRamOffset;
|
||||
|
|
|
@ -232,20 +232,17 @@ public final class RomAttributeParser {
|
|||
}
|
||||
|
||||
public static int parseFileSize(String input) throws NumberFormatException {
|
||||
try {
|
||||
return Integer.parseInt(input);
|
||||
} catch (NumberFormatException ex) {
|
||||
if (input.substring(input.length() - 2).equalsIgnoreCase("kb")) {
|
||||
return Integer.parseInt(input.substring(0, input.length() - 2)) * 1024;
|
||||
}
|
||||
else if (input.substring(input.length() - 2).equalsIgnoreCase("mb")) {
|
||||
return Integer.parseInt(input.substring(0, input.length() - 2)) * 1024 * 1024;
|
||||
}
|
||||
else if (input.substring(input.length() - 1).equalsIgnoreCase("b")) {
|
||||
return Integer.parseInt(input.substring(0, input.length() - 1));
|
||||
}
|
||||
throw new NumberFormatException();
|
||||
if (input.substring(input.length() - 2).equalsIgnoreCase("kb")) {
|
||||
return Integer.parseInt(input.substring(0, input.length() - 2)) * 1024;
|
||||
}
|
||||
else if (input.substring(input.length() - 2).equalsIgnoreCase("mb")) {
|
||||
return Integer.parseInt(input.substring(0, input.length() - 2)) * 1024 * 1024;
|
||||
}
|
||||
else if (input.substring(input.length() - 1).equalsIgnoreCase("b")) {
|
||||
return Integer.parseInt(input.substring(0, input.length() - 1));
|
||||
}
|
||||
|
||||
return Integer.parseInt(input);
|
||||
}
|
||||
|
||||
public static byte[] floatToByte(float input, Settings.Endian endian, Settings.Endian memModelEndian) {
|
||||
|
|
Loading…
Reference in New Issue