Skip to content

Commit

Permalink
Make it so that in UINumberBox, typing a - anywhere negates the number.
Browse files Browse the repository at this point in the history
  • Loading branch information
20kdc committed Oct 12, 2017
1 parent 0e19c6d commit 294e994
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/gabien/ui/UINumberBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,18 @@ public void updateAndRender(int ox, int oy, double DeltaTime, boolean selected,
if (selected && (!readOnly)) {
int NNum = number;
String ss = igd.maintain(ox, oy + (textHeight / 2), elementBounds.width, String.valueOf(NNum));
int lastMinusIdx = ss.lastIndexOf("-");
boolean doInvertLater = false;
if (lastMinusIdx > 0) {
String pre = ss.substring(0, lastMinusIdx);
String post = ss.substring(lastMinusIdx + 1);
ss = pre + post;
doInvertLater = true;
}
try {
NNum = Integer.parseInt(ss);
if (doInvertLater)
NNum = -NNum;
} catch (Exception e) {
NNum = 0;
}
Expand Down

0 comments on commit 294e994

Please sign in to comment.