trackeditor: don't warn when reading an integer and getting a floating point whole number

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9280 30fe4595-0a0c-4342-8851-515496e4dcbd
This commit is contained in:
iobyte 2024-01-24 17:05:13 +00:00
parent 0cfac62f32
commit 9cc818b430
1 changed files with 34 additions and 20 deletions

View File

@ -1200,26 +1200,40 @@ public class XmlReader
return out;
}
public synchronized int getAttrIntValue(Element element,
String name)
public synchronized int getAttrIntValue(Element element, String name)
{
int out = Integer.MAX_VALUE;
Element e = getChildWithName(element, name);
if (e != null)
{
if (e.getName().equals("attnum"))
{
try
{
out = Integer.decode(e.getAttributeValue("val"));
}
catch (NumberFormatException exception)
{
String msg = filename + " : " + ((MyElement)e).getLineNumber() + " : " + e.getAttribute("name").getValue() + " : " + e.getAttributeValue("val");
JOptionPane.showMessageDialog(editorFrame, msg, "Invalid number", JOptionPane.ERROR_MESSAGE);
}
}
}
return out;
int out = Integer.MAX_VALUE;
Element e = getChildWithName(element, name);
if (e != null)
{
if (e.getName().equals("attnum"))
{
try
{
out = Integer.decode(e.getAttributeValue("val"));
}
catch (NumberFormatException exception1)
{
try
{
double value = Double.parseDouble(e.getAttributeValue("val"));
if (Math.floor(value) != value)
{
String msg = filename + " : " + ((MyElement)e).getLineNumber() + " : " + e.getAttribute("name").getValue() + " : " + e.getAttributeValue("val");
JOptionPane.showMessageDialog(editorFrame, msg, "Invalid number", JOptionPane.ERROR_MESSAGE);
}
out = (int) value;
}
catch (NumberFormatException exception2)
{
String msg = filename + " : " + ((MyElement)e).getLineNumber() + " : " + e.getAttribute("name").getValue() + " : " + e.getAttributeValue("val");
JOptionPane.showMessageDialog(editorFrame, msg, "Invalid number", JOptionPane.ERROR_MESSAGE);
}
}
}
}
return out;
}
}