Fixed calculator
This commit is contained in:
parent
0b2c42533b
commit
cf95e96345
|
@ -25,7 +25,7 @@ public class CalculatorComponent {
|
|||
@Reference
|
||||
private VrGem4LocaleService localeService;
|
||||
|
||||
private final static String I18N_BUNDLE = "love.distributedrebirth.gdxapp4d.app.calculator.Main";
|
||||
private final static String I18N_BUNDLE = "love.distributedrebirth.gdxapp4d.app.calculator.Messages";
|
||||
private final DeskAppLauncher launcher;
|
||||
|
||||
public CalculatorComponent() {
|
||||
|
|
|
@ -16,11 +16,13 @@ import love.distributedrebirth.unicode4d.BaseGlyphSet;
|
|||
public class CalculatorDeskApp extends AbstractDeskApp implements DeskAppRenderer {
|
||||
|
||||
private ResourceBundle bundle;
|
||||
private int valueNum = 0;
|
||||
private String value = "";
|
||||
private String valueLoc = "";
|
||||
private String valueArg = "";
|
||||
private Operation operation = Operation.NONE;
|
||||
private ImInt selectedNumberGlyph = new ImInt();
|
||||
private float buttonSize = 64f;
|
||||
|
||||
public CalculatorDeskApp(ResourceBundle bundle) {
|
||||
this.bundle = bundle;
|
||||
|
@ -52,107 +54,123 @@ public class CalculatorDeskApp extends AbstractDeskApp implements DeskAppRendere
|
|||
}
|
||||
String[] items = new String[bases.size()];
|
||||
items = bases.toArray(items);
|
||||
ImGui.combo(getTxt("selectedNumberGlyph"), selectedNumberGlyph, items);
|
||||
boolean changedLoc = ImGui.combo(getTxt("selectedNumberGlyph"), selectedNumberGlyph, items);
|
||||
String selectedItem = items[selectedNumberGlyph.get()];
|
||||
BaseGlyphSet baseNumber = BaseGlyphSet.valueOf(selectedItem);
|
||||
|
||||
if (changedLoc) {
|
||||
valueLoc = baseNumber.BȍőnPrintNumber10(valueNum, 9999999);
|
||||
}
|
||||
|
||||
ImGui.text("Value:");
|
||||
ImGui.sameLine();
|
||||
ImGui.text(valueLoc);
|
||||
ImGui.separator();
|
||||
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(0))) {
|
||||
value+="0";
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(0);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(1))) {
|
||||
value+="1";
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(1);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(2))) {
|
||||
value+="2";
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(2);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(3))) {
|
||||
value+="3";
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(3);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(4))) {
|
||||
value+="4";
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(4);
|
||||
}
|
||||
|
||||
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(5))) {
|
||||
value+="5";
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(5);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(6))) {
|
||||
value+="6";
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(6);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(7))) {
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(7), buttonSize, buttonSize)) {
|
||||
value+="7";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(7);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(8))) {
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(8), buttonSize, buttonSize)) {
|
||||
value+="8";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(8);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(9))) {
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(9), buttonSize, buttonSize)) {
|
||||
value+="9";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(9);
|
||||
}
|
||||
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("/", buttonSize, buttonSize)) {
|
||||
valueArg=value;
|
||||
value="";
|
||||
valueLoc="";
|
||||
operation = Operation.DIVIDE;
|
||||
}
|
||||
|
||||
if (ImGui.button("C")) {
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(4), buttonSize, buttonSize)) {
|
||||
value+="4";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(4);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(5), buttonSize, buttonSize)) {
|
||||
value+="5";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(5);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(6), buttonSize, buttonSize)) {
|
||||
value+="6";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(6);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("*", buttonSize, buttonSize)) {
|
||||
valueArg=value;
|
||||
value="";
|
||||
valueLoc="";
|
||||
operation = Operation.MULTIPLY;
|
||||
}
|
||||
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(1), buttonSize, buttonSize)) {
|
||||
value+="1";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(1);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(2), buttonSize, buttonSize)) {
|
||||
value+="2";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(2);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(3), buttonSize, buttonSize)) {
|
||||
value+="3";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(3);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("-", buttonSize, buttonSize)) {
|
||||
valueArg=value;
|
||||
value="";
|
||||
valueLoc="";
|
||||
operation = Operation.MINUS;
|
||||
}
|
||||
|
||||
if (ImGui.button(baseNumber.BȍőnNumber10().BȍőnCharFor(0), buttonSize, buttonSize)) {
|
||||
value+="0";
|
||||
valueNum = Integer.parseInt(value);
|
||||
valueLoc+=baseNumber.BȍőnNumber10().BȍőnCharFor(0);
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("C", buttonSize, buttonSize)) {
|
||||
valueNum = 0;
|
||||
value="";
|
||||
valueLoc="";
|
||||
valueArg="";
|
||||
operation = Operation.NONE;
|
||||
}
|
||||
if (ImGui.button("+")) {
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("+", buttonSize, buttonSize)) {
|
||||
valueArg=value;
|
||||
value="";
|
||||
valueLoc="";
|
||||
operation = Operation.PLUS;
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("-")) {
|
||||
valueArg=value;
|
||||
value="";
|
||||
valueLoc="";
|
||||
operation = Operation.MINUS;
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("*")) {
|
||||
valueArg=value;
|
||||
value="";
|
||||
valueLoc="";
|
||||
operation = Operation.MULTIPLY;
|
||||
}
|
||||
ImGui.sameLine();
|
||||
if (ImGui.button("/")) {
|
||||
valueArg=value;
|
||||
value="";
|
||||
valueLoc="";
|
||||
operation = Operation.DIVIDE;
|
||||
}
|
||||
if (ImGui.button("=")) {
|
||||
if (ImGui.button("=", buttonSize, buttonSize)) {
|
||||
if (value.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int v2 = Integer.parseInt(value);
|
||||
if (valueArg.isEmpty()) {
|
||||
valueLoc = baseNumber.BȍőnPrintNumber10(v2, 9999999);;
|
||||
valueLoc = baseNumber.BȍőnPrintNumber10(v2, 9999999);
|
||||
return;
|
||||
}
|
||||
int v1 = Integer.parseInt(valueArg);
|
||||
|
||||
|
@ -173,8 +191,9 @@ public class CalculatorDeskApp extends AbstractDeskApp implements DeskAppRendere
|
|||
default:
|
||||
break;
|
||||
}
|
||||
value = "" + result;
|
||||
valueLoc = baseNumber.BȍőnPrintNumber10(result, 9999999);;
|
||||
valueNum = result;
|
||||
value = "" + valueNum;
|
||||
valueLoc = baseNumber.BȍőnPrintNumber10(valueNum, 9999999);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue