Skip to content
Snippets Groups Projects
Commit dfc4acbe authored by deuce's avatar deuce
Browse files

Add default capability for numeric inputs.

Ensure that node messages and telegrams are delivered during input.
parent 7dd0dd2b
No related branches found
No related tags found
No related merge requests found
...@@ -2379,6 +2379,8 @@ function DeletePlayer(player) ...@@ -2379,6 +2379,8 @@ function DeletePlayer(player)
twmsg.writeln(" - "+player.Alias+" deleted from game"); twmsg.writeln(" - "+player.Alias+" deleted from game");
} }
var lastmisc=system.node_list[bbs.node_num-1].misc;
var laststatus=system.node_list[bbs.node_num-1].status;
function InputFunc(values) function InputFunc(values)
{ {
var str=''; var str='';
...@@ -2386,7 +2388,7 @@ function InputFunc(values) ...@@ -2386,7 +2388,7 @@ function InputFunc(values)
var insertmode=true; var insertmode=true;
var key; var key;
var origattr=console.attributes; var origattr=console.attributes;
var matchstr='' var matchval='';
console.line_counter=0; console.line_counter=0;
console.attributes="N"; console.attributes="N";
...@@ -2394,12 +2396,28 @@ InputFuncMainLoop: ...@@ -2394,12 +2396,28 @@ InputFuncMainLoop:
for(;;) { for(;;) {
key=console.inkey(100); key=console.inkey(100);
if(key == '') { if(key == '') {
/* Node status check */
var newmisc=system.node_list[bbs.node_num-1].misc;
var newstatus=system.node_list[bbs.node_num-1].status;
if(newmisc != lastmisc || newstatus != laststatus) {
console.saveline();
bbs.nodesync();
console.write("\r");
if(console.line_counter!=0) {
console.crlf();
console.line_counter=0;
}
console.restoreline();
lastmisc=system.node_list[bbs.node_num-1].misc;
laststatus=system.node_list[bbs.node_num-1].status;
}
/* Busy loop checking */ /* Busy loop checking */
} }
else { else {
switch(key) { switch(key) {
case '\x1b': /* Escape */ case '\x1b': /* Escape */
matchstr=''; matchval='';
pos=0; pos=0;
break InputFuncMainLoop; break InputFuncMainLoop;
case '\r': case '\r':
...@@ -2424,30 +2442,35 @@ InputFuncMainLoop: ...@@ -2424,30 +2442,35 @@ InputFuncMainLoop:
var value; var value;
var exact_match=false; var exact_match=false;
var longer_match=false; var longer_match=false;
matchstr=''; matchval='';
for(value in values) { for(value in values) {
if(typeof(values[value])=='string') { if(typeof(values[value])=='string') {
var ucv=values[value].toUpperCase(); var ucv=values[value].toUpperCase();
var ucs=str.toUpperCase(); var ucs=str.toUpperCase();
if(ucv==ucs) { if(ucv==ucs) {
exact_match=true; exact_match=true;
matchstr=values[value]; matchval=values[value];
} }
else if(ucv.indexOf(ucs)==0) else if(ucv.indexOf(ucs)==0)
longer_match=true; longer_match=true;
} }
else if(typeof(values[value])=='object') { else if(typeof(values[value])=='object') {
if(str.search(/^[0-9]*$/)!=-1) {
var min=0; var min=0;
var max=4294967296; var max=4294967295;
var cur=parseInt(str); var def=0;
if(values[value].min != undefined) if(values[value].min != undefined)
min=values[value].min; min=values[value].min;
if(values[value].max != undefined) if(values[value].max != undefined)
max=values[value].max; max=values[value].max;
if(values[value].def != undefined)
def=values[value].def;
if(str.search(/^[0-9]*$/)!=-1) {
var cur=def;
if(pos > 0)
cur=parseInt(str);
if(cur >= min && cur <= max) { if(cur >= min && cur <= max) {
exact_match=true; exact_match=true;
matchstr=cur.toString(); matchval=cur;
} }
if(cur*10 <= max) if(cur*10 <= max)
longer_match=true; longer_match=true;
...@@ -2470,8 +2493,8 @@ InputFuncMainLoop: ...@@ -2470,8 +2493,8 @@ InputFuncMainLoop:
console.write('\x08'); console.write('\x08');
pos--; pos--;
} }
console.write(matchstr); console.cleartoeol(origattr);
console.attributes=origattr; console.write(matchstr.toString());
console.crlf(); console.crlf();
return(matchstr); return(matchstr);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment