1
0
Fork 0

Better long pressed CLR and check numeric format on plus/minus

This commit is contained in:
Inuyaksa 2022-01-17 22:19:29 +01:00
parent 15221a3e20
commit 871c645fba
3 changed files with 69 additions and 38 deletions

View file

@ -1678,7 +1678,7 @@
<object-name>overfly</object-name>
<action>
<button>0</button>
<repeatable>true</repeatable>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu.button("OVFY", 0);</script>
@ -1703,11 +1703,23 @@
<action>
<button>0</button>
<repeatable>true</repeatable>
<binding>
<command>property-adjust</command>
<property>/MCDU[0]/clrbtn-timeout</property>
<step>1</step>
<min>0</min>
<max>6</max>
<wrap>false</wrap>
</binding>
<binding>
<command>nasal</command>
<script>mcdu.button("CLR", 0, "down");</script>
<script>mcdu.button("LONGCLR", 0);</script>
<condition>
<and>
<equals>
<property>/MCDU[0]/clrbtn-timeout</property>
<value>5</value>
</equals>
<greater-than-equals>
<property>systems/electrical/bus/ac-1</property>
<value>110</value>
@ -1722,9 +1734,13 @@
<mod-up>
<binding>
<command>nasal</command>
<script>mcdu.button("CLR", 0, "up");</script>
<script>mcdu.button("CLR", 0);</script>
<condition>
<and>
<less-than>
<property>/MCDU[0]/clrbtn-timeout</property>
<value>5</value>
</less-than>
<greater-than-equals>
<property>systems/electrical/bus/ac-1</property>
<value>110</value>
@ -1736,6 +1752,11 @@
</and>
</condition>
</binding>
<binding>
<command>property-assign</command>
<property>/MCDU[0]/clrbtn-timeout</property>
<value>0</value>
</binding>
</mod-up>
</action>
</animation>

View file

@ -1678,7 +1678,7 @@
<object-name>overfly</object-name>
<action>
<button>0</button>
<repeatable>true</repeatable>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>mcdu.button("OVFY", 1);</script>
@ -1703,11 +1703,23 @@
<action>
<button>0</button>
<repeatable>true</repeatable>
<binding>
<command>property-adjust</command>
<property>/MCDU[1]/clrbtn-timeout</property>
<step>1</step>
<min>0</min>
<max>6</max>
<wrap>false</wrap>
</binding>
<binding>
<command>nasal</command>
<script>mcdu.button("CLR", 1, "down");</script>
<script>mcdu.button("LONGCLR", 1);</script>
<condition>
<and>
<equals>
<property>/MCDU[1]/clrbtn-timeout</property>
<value>5</value>
</equals>
<greater-than-equals>
<property>systems/electrical/bus/ac-2</property>
<value>110</value>
@ -1722,9 +1734,13 @@
<mod-up>
<binding>
<command>nasal</command>
<script>mcdu.button("CLR", 1, "up");</script>
<script>mcdu.button("CLR", 1);</script>
<condition>
<and>
<less-than>
<property>/MCDU[1]/clrbtn-timeout</property>
<value>5</value>
</less-than>
<greater-than-equals>
<property>systems/electrical/bus/ac-2</property>
<value>110</value>
@ -1736,6 +1752,11 @@
</and>
</condition>
</binding>
<binding>
<command>property-assign</command>
<property>/MCDU[1]/clrbtn-timeout</property>
<value>0</value>
</binding>
</mod-up>
</action>
</animation>

View file

@ -1499,8 +1499,6 @@ var pagebutton = func(btn, i) {
}
}
var buttonCLRDown = [0,0]; # counter for down event
var button = func(btn, i, event = "") {
page = pageNode[i].getValue();
if (page != "MCDU") {
@ -1510,41 +1508,32 @@ var button = func(btn, i, event = "") {
} else if (btn == "SP") {
mcdu_scratchpad.scratchpads[i].addChar(" ");
} else if (btn == "CLR") {
if (event == "down") {
if (size(scratchpad) > 0) {
if (buttonCLRDown[i] > 4) {
mcdu_scratchpad.scratchpads[i].empty();
}
buttonCLRDown[i] = buttonCLRDown[i] + 1;
}
}
else if (event == "" or buttonCLRDown[i]<=4) {
buttonCLRDown[i] = 0;
#var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad; <- useless??
if (size(scratchpad) == 0) {
mcdu_scratchpad.scratchpads[i].addChar("CLR");
} else {
mcdu_scratchpad.scratchpads[i].clear();
}
} else { # up with buttonCLRDown[i]>4
buttonCLRDown[i] = 0;
if (size(scratchpad) == 0) {
mcdu_scratchpad.scratchpads[i].addChar("CLR");
} else {
mcdu_scratchpad.scratchpads[i].clear();
}
} else if (btn == "LONGCLR") {
mcdu_scratchpad.scratchpads[i].empty();
} else if (btn == "DOT") {
mcdu_scratchpad.scratchpads[i].addChar(".");
} else if (btn == "PLUSMINUS") {
if (right(mcdu_scratchpad.scratchpads[i].scratchpad, 1) == "-") {
mcdu_scratchpad.scratchpads[i].clear();
mcdu_scratchpad.scratchpads[i].addChar("+");
} else if (right(mcdu_scratchpad.scratchpads[i].scratchpad, 1) == "+") {
mcdu_scratchpad.scratchpads[i].clear();
if (size(scratchpad)==0) {
mcdu_message(i, "NOT ALLOWED");
} else if (isint(scratchpad)==1) {
mcdu_scratchpad.scratchpads[i].addChar("-");
} else {
mcdu_scratchpad.scratchpads[i].addChar("-");
var _toggle = right(scratchpad,1);
if (find(_toggle,"-+")!=-1) {
_toggle = (_toggle == "-") ? "+" : "-";
mcdu_scratchpad.scratchpads[i].clear();
mcdu_scratchpad.scratchpads[i].addChar(_toggle);
} else {
mcdu_message(i, "NOT ALLOWED");
}
}
} else if (btn == "OVFY") {
if (mcdu_scratchpad.scratchpads[i].scratchpad == "") {
if (size(scratchpad)==0) {
mcdu_scratchpad.scratchpads[i].addChar("@");
} else {
mcdu_message(i, "NOT ALLOWED");