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