void load_property(char * desc,int type, void * ad) { char newdesc[60]; char param[20000]; char * propstart; int pos; low_chars(newdesc, desc); // report(newdesc); strcat(newdesc,"="); propstart=strstr(GLOBAL.configbuffer,newdesc); if (propstart) { while ((*propstart)&&(*propstart!='=')&&(*propstart!=10)&&(*propstart!=13)) propstart++; if (*propstart=='=') { propstart++; while (*propstart==' ') propstart++; pos=0; while ((*propstart!=10)&&(*propstart!=13)&&(*propstart)&&pos<20000) param[pos++]=*propstart++; param[pos]=0; switch (type) { case P_INT: sscanf(param,"%d",(int *)ad); break; case P_FLOAT: sscanf(param,"%f",(float *)ad); break; case P_STRING: strcpy ((char *)ad,param); break; } } } // else report_error("property not found");} }
void init_path() { char * newpath; GetModuleFileName(NULL,GLOBAL.resourcepath,sizeof(GLOBAL.resourcepath)); low_chars(GLOBAL.resourcepath,GLOBAL.resourcepath); newpath=strstr(GLOBAL.resourcepath,"brainbay.exe"); if (!newpath) report_error("filename error: brainbay.exe not found"); else *newpath=0; }
void save_property(HANDLE hFile, char * desc,int type, void * ad) { char str[20000]; DWORD dwWritten; char nl[3]="\r\n"; low_chars(str,desc);if (strcmp(str,"end object")) strcat(str,"="); else strcat(str,nl); WriteFile(hFile, str, strlen(str), &dwWritten, NULL); if (type!=P_END) { switch (type) { case P_INT: sprintf(str,"%d",*((int *)ad)); break; case P_FLOAT: sprintf(str,"%.4f",*((float *)ad)); break; case P_STRING: strcpy (str,(char *)ad); break; } strcat(str,nl); WriteFile(hFile, str, strlen(str), &dwWritten, NULL); } }
void SPELLEROBJ::work(void) { int i; if (mode==0) { enter=0; if (((input!=63) && (oldinput==63)) || (input!=INVALID_VALUE) && (oldinput==INVALID_VALUE)) { enter=1; switchtime=0; } oldinput=input; if (switchtime++> speed) { switchtime=0; select++; if (select>=selections) { select=0; selstart=0; selbegin=0; selections=entries; selend=selections; delchars=0; //selstart+=selections; //if (selstart>selend) selstart=0; } if (displayWnd) InvalidateRect(displayWnd,NULL,FALSE); } } if (mode==1) { enter=0; if (waitres) { if (input!=(int)oldinput) waitres=0; } else { oldpaddle=paddle; paddle = ((int) size_value(in_ports[1].in_min,in_ports[1].in_max,input2, 16.0f ,0.0f,0)); if (paddle!= oldpaddle) { select = paddle % (selections+1) -1 ; presstime=0; } if (select==-1) idletime++; else { idletime=0; presstime++;} if (idletime>idle) { idletime=0; select=-1; oldpaddle=paddle+1; if (selstart+selections<selend) selstart+=selections; // if (selstart>selend) else { selstart=0; selbegin=0; selections=entries; selend=selections; delchars=0; } InvalidateRect(displayWnd,NULL,FALSE); } if (input!=15) { get_suggestions(); waitres=1; oldinput=input; idletime=0; presstime=0; select=-1; } if (presstime>press) {presstime=0; enter=1; idletime=0; } if (displayWnd && (select!=os)) InvalidateRect(displayWnd,NULL,FALSE); os=select; } } if (mode==2) { if (waitres) { if (input==15) waitres=0; } else { if (input==15) idletime++; else idletime=0; if (idletime>idle) { idletime=0; select=-1; if (selstart+selections<selend) selstart+=selections; // if (selstart>selend) else { selstart=0; selbegin=0; selections=entries; selend=selections; delchars=0; } InvalidateRect(displayWnd,NULL,FALSE); } if ((input!=oldinput) || (input==15)) presstime=0; else { if (++presstime>press) { if (input==14) { selstart=0; selbegin=0; selections=entries; selend=selections; } if (input==13) get_suggestions(); if (input==7) { select--; if (select<0) select=selections-1; enter=2; } if (input==11) { select++; if (select==selections) select=-1; enter=2; } presstime=1; } } if ((enter==2) && (idletime>180) && (select>=0)) {enter=1; waitres=1;} if (displayWnd && (select!=os)) InvalidateRect(displayWnd,NULL,FALSE); os=select; } oldinput=input; } if (enter==1) { enter=0; switch( dict[selstart+select].type) { case FINAL_CHARACTERS: { char c; int u,keep=0; c=dict[selstart+select].data[0]; switch (c) { case '<': if (strlen(word)>0) word[strlen(word)-1]=0; if (directsend) send_key(8); break; case 1: if (!directsend) send_word(word); if (autolearn) learn_words(); strcpy(word,""); break; case 2: for (u=0;u<entries;u++) { if (dict[u].data[0]>20) // not a command { up_chars(dict[u].data,dict[u].data); up_chars(dict[u].tag,dict[u].tag); } } upchar=1; break; case 3: get_suggestions(); InvalidateRect(displayWnd,NULL,FALSE); keep=1; //waitres=1; oldinput=input; idletime=0; presstime=0; switchtime=0; //select=-1; break; case 4: get_dictionary(); InvalidateRect(displayWnd,NULL,FALSE); keep=1; idletime=0; presstime=0; switchtime=0; break; default: if (delchars) { word[strlen(word)-delchars]=0; strcat(word,dict[selstart+select].data); strcat(word," "); if (directsend) { send_word(dict[selstart+select].data); send_key(' '); } delchars=0; } else { strcat(word,dict[selstart+select].data); if (directsend) send_word(dict[selstart+select].data); if (strlen(dict[selstart+select].data)>1) { strcat(word," "); if (directsend) send_key(' '); } if ((dict[selstart+select].data[0]>20)&&(upchar)) { upchar=0; for (u=0;u<entries;u++) { if (dict[u].data[0]>20) { low_chars(dict[u].data,dict[u].data); low_chars(dict[u].tag,dict[u].tag); } } } } } if (!keep) { select=-1; selstart=0;selbegin=0;selections=entries;selend=selections; make_suggestions(); } } break; case EXTEND_CHARACTERS: i=0; while (dict[selstart+select].data[i]) { dict[START_DYNAMIC+i].data[0]=dict[selstart+select].data[i]; dict[START_DYNAMIC+i].data[1]=0; dict[START_DYNAMIC+i].tag[0]=dict[selstart+select].tag[i]; dict[START_DYNAMIC+i].tag[1]=0; dict[START_DYNAMIC+i].type=FINAL_CHARACTERS; i++; } selstart=START_DYNAMIC;selbegin=START_DYNAMIC; selend=START_DYNAMIC+i-1; selections=i; select=-1; break; case DICTIONARY: strcpy(fn,GLOBAL.resourcepath); strcat(fn,"dictionary\\"); strcat(fn,dict[selstart+select].data); load_dictionary(fn); make_suggestions(); select=-1; selstart=0;selbegin=0;selections=entries;selend=selections; break; } if (displayWnd) InvalidateRect(displayWnd,NULL,FALSE); } }