- Timestamp:
- 12/01/09 07:17:04 (3 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
core/gui.c (modified) (1 diff)
-
core/luascript.c (modified) (2 diffs)
-
core/script.c (modified) (8 diffs)
-
include/script.h (modified) (3 diffs)
-
lib/ubasic/camera_functions.c (modified) (1 diff)
-
lib/ubasic/tokenizer.c (modified) (1 diff)
-
lib/ubasic/tokenizer.h (modified) (1 diff)
-
lib/ubasic/ubasic.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/gui.c
r111 r172 2182 2182 --show_script_console; 2183 2183 md_draw_grid(); 2184 script_console_draw( );2184 script_console_draw(auto_redraw); 2185 2185 } 2186 2186 } -
trunk/core/luascript.c
r135 r172 64 64 { 65 65 script_console_clear(); 66 return 0; 67 } 68 69 static int luaCB_set_console_layout( lua_State* L ) 70 { 71 script_console_set_layout(luaL_checknumber( L, 1 ),luaL_checknumber( L, 2 ),luaL_checknumber( L, 3 ),luaL_checknumber( L, 4 )); 72 return 0; 73 } 74 75 static int luaCB_set_console_autoredraw( lua_State* L ) 76 { 77 script_console_set_autoredraw(luaL_checknumber( L, 1 )); 78 return 0; 79 } 80 81 static int luaCB_console_redraw( lua_State* L ) 82 { 83 script_console_redraw(); 66 84 return 0; 67 85 } … … 1085 1103 FUNC(sleep); 1086 1104 FUNC(cls); 1105 FUNC(set_console_layout); 1106 FUNC(set_console_autoredraw); 1107 FUNC(console_redraw); 1087 1108 1088 1109 lua_pushlightuserdata( L, kbd_sched_click ); -
trunk/core/script.c
r11 r172 10 10 //------------------------------------------------------------------- 11 11 12 #define SCRIPT_CONSOLE_NUM_LINES 5 13 #define SCRIPT_CONSOLE_LINE_LENGTH 25 14 #define SCRIPT_CONSOLE_X 0 15 #define SCRIPT_CONSOLE_Y (14-SCRIPT_CONSOLE_NUM_LINES) 12 #define SCRIPT_MAX_CONSOLE_LINES 14 13 #define SCRIPT_MAX_LINE_LENGTH 45 16 14 17 15 //------------------------------------------------------------------- … … 19 17 char cfg_name[100] = "\0"; 20 18 char cfg_set_name[100] = "\0"; 19 int script_console_num_lines, script_console_line_length, script_console_x, script_console_y, auto_redraw=1; 21 20 22 21 static const char *ubasic_script_default = … … 76 75 static char script_params_update[SCRIPT_NUM_PARAMS]; 77 76 static int script_loaded_params[SCRIPT_NUM_PARAMS]; 78 static char script_console_buf[SCRIPT_CONSOLE_NUM_LINES][SCRIPT_CONSOLE_LINE_LENGTH+1]; 77 //static char script_console_buf[script_console_num_lines][script_console_line_length+1]; 78 static char **script_console_buf; 79 79 static int script_con_start_line=0; // oldest valid line in console 80 80 static int script_con_num_lines=0; // number of valid lines … … 322 322 struct stat st; 323 323 324 auto_redraw=1; 325 script_console_num_lines=5; 326 script_console_line_length=25; 327 script_console_y=SCRIPT_MAX_CONSOLE_LINES-script_console_num_lines; 328 script_console_x=0; 329 script_console_buf=malloc(script_console_num_lines*sizeof(char*)); 330 for (i=0;i<script_console_num_lines;i++){ 331 script_console_buf[i]=malloc(script_console_line_length*sizeof(char)+1); 332 } 333 script_con_start_line=0; 334 script_con_num_lines=0; 335 324 336 // save_params_values(0); 325 337 … … 394 406 register int i; 395 407 396 for (i=0; i< SCRIPT_CONSOLE_NUM_LINES; ++i) {408 for (i=0; i<script_console_num_lines; ++i) { 397 409 script_console_buf[i][0]=0; 398 410 } 399 411 script_con_num_lines=script_con_start_line=0; 400 draw_restore();412 if(auto_redraw) draw_restore(); 401 413 } 402 414 403 415 //------------------------------------------------------------------- 404 416 static inline int script_con_line_index(int i) { 405 return i%SCRIPT_CONSOLE_NUM_LINES; 406 } 407 408 void script_console_draw() { 409 int i,c,l; 417 return i%script_console_num_lines; 418 } 419 420 void script_console_draw(int drawing) { 421 int i,c,l; 422 if(drawing){ 410 423 for(c = 0; c < script_con_num_lines; ++c) { 411 i=script_con_line_index(script_con_start_line+c); 412 l=strlen(script_console_buf[i]); 413 draw_txt_string(SCRIPT_CONSOLE_X, SCRIPT_CONSOLE_Y+SCRIPT_CONSOLE_NUM_LINES-script_con_num_lines+c, script_console_buf[i], MAKE_COLOR(COLOR_BG, COLOR_FG)); 414 for (; l<SCRIPT_CONSOLE_LINE_LENGTH; ++l) 415 draw_txt_char(SCRIPT_CONSOLE_X+l, SCRIPT_CONSOLE_Y+SCRIPT_CONSOLE_NUM_LINES-script_con_num_lines+c, ' ', MAKE_COLOR(COLOR_BG, COLOR_FG)); 416 } 424 i=script_con_line_index(script_con_start_line+c); 425 l=strlen(script_console_buf[i]); 426 draw_txt_string(script_console_x, script_console_y+script_console_num_lines-script_con_num_lines+c, script_console_buf[i], MAKE_COLOR(COLOR_BG, COLOR_FG)); 427 for (; l<script_console_line_length; ++l) 428 draw_txt_char(script_console_x+l, script_console_y+script_console_num_lines-script_con_num_lines+c, ' ', MAKE_COLOR(COLOR_BG, COLOR_FG)); 429 } 430 } 417 431 } 418 432 … … 464 478 //------------------------------------------------------------------- 465 479 void script_console_start_line() { 466 if ( SCRIPT_CONSOLE_NUM_LINES==script_con_num_lines) {480 if (script_console_num_lines==script_con_num_lines) { 467 481 script_con_start_line=script_con_line_index(script_con_start_line+1); 468 482 } … … 481 495 cur = script_console_buf[script_con_line_index(script_con_start_line+script_con_num_lines-1)]; 482 496 curlen = strlen(cur); 483 left = SCRIPT_CONSOLE_LINE_LENGTH-curlen;497 left = script_console_line_length-curlen; 484 498 if(strlen(str) > left) { 485 499 strncpy(cur+curlen,str,left); 486 cur[ SCRIPT_CONSOLE_LINE_LENGTH]=0;500 cur[script_console_line_length]=0; 487 501 script_console_start_line(); 488 502 str+=left; … … 504 518 write(print_screen_d, &nl, 1); 505 519 } 506 script_console_draw(); 507 } 508 //------------------------------------------------------------------- 509 //------------------------------------------------------------------- 510 //------------------------------------------------------------------- 520 script_console_draw(auto_redraw); 521 } 522 //------------------------------------------------------------------- 523 void script_console_set_layout(int x1, int y1, int x2, int y2) { //untere linke Ecke(x1,y1), obere reche Ecke(x2,y2) 524 int i,len,newLinesCount,newLineLength,newNumLines,lineDelta,idx; 525 char **tmp; 526 if(x1>=0 && x1<x2 && x1<=SCRIPT_MAX_LINE_LENGTH && y1>=0 && y1<y2 && y1<=SCRIPT_MAX_CONSOLE_LINES && x2<=SCRIPT_MAX_LINE_LENGTH && y2<=SCRIPT_MAX_CONSOLE_LINES) { 527 //In neuen Puffer kopieren 528 newLineLength=x2-x1; 529 newLinesCount=y2-y1; 530 if(newLineLength!=script_console_line_length || newLinesCount!=script_console_num_lines) { 531 lineDelta=script_con_num_lines-newLinesCount; 532 if(lineDelta<0) lineDelta=0; 533 newNumLines=0; 534 tmp=malloc(newLinesCount*sizeof(char*)); //realloc Nachbildung 535 for(i=0;i<newLinesCount;i++){ 536 tmp[i]=malloc(newLineLength*sizeof(char)+1); 537 if(i<script_con_num_lines){ 538 newNumLines++; 539 idx=script_con_line_index(script_con_start_line+i+lineDelta); 540 len=strlen(script_console_buf[idx]); 541 if(len>newLineLength) len=newLineLength; 542 strncpy(tmp[i],script_console_buf[idx],len); 543 tmp[i][len]=0x0; 544 } else tmp[i][0]=0x0; 545 } 546 //Speicher freigeben 547 for(i=0;i<script_console_num_lines;i++) { 548 free(script_console_buf[i]); 549 } 550 free(script_console_buf); 551 //neue Werte setzten 552 script_console_buf=tmp; 553 script_con_start_line=0; 554 script_con_num_lines=newNumLines; 555 script_console_num_lines=newLinesCount; 556 script_console_line_length=newLineLength; 557 } 558 script_console_x=x1; 559 script_console_y=SCRIPT_MAX_CONSOLE_LINES-y2; 560 if(auto_redraw) draw_restore(); 561 } 562 } 563 //------------------------------------------------------------------- 564 void script_console_set_autoredraw(int value){ 565 auto_redraw=value; 566 } 567 //------------------------------------------------------------------- 568 void script_console_redraw(){ 569 draw_restore(); 570 script_console_draw(1); 571 } 572 //------------------------------------------------------------------- -
trunk/include/script.h
r12 r172 13 13 extern char script_params[SCRIPT_NUM_PARAMS][28]; 14 14 extern int script_param_order[SCRIPT_NUM_PARAMS]; 15 extern int auto_redraw; 15 16 16 17 //------------------------------------------------------------------- … … 18 19 extern void script_console_clear(); 19 20 extern void script_console_add_line(const char *str); 20 extern void script_console_draw( );21 extern void script_console_draw(int drawing); 21 22 extern void script_print_screen_init(); 22 23 extern void script_print_screen_end(); … … 24 25 extern int load_params_values(const char *fn, int update_vars, int read_param_set); 25 26 extern void save_params_values(int unconditional); 27 extern void script_console_set_layout(int x1, int y1, int x2, int y2); 28 extern void script_console_set_autoredraw(int value); 29 extern void script_console_redraw(); 26 30 //------------------------------------------------------------------- 27 31 #endif -
trunk/lib/ubasic/camera_functions.c
r14 r172 130 130 } 131 131 132 void script_console_set_layout(int x1, int y1, int x2, int y2) { 133 printf(">>> set console layout to %d %d %d %d\n", x1,y1,x2,y2); 134 } 135 136 void script_console_set_autoredraw(int value) { 137 printf(">>> set console auto_redraw to %d\n", x1); 138 } 139 140 void script_console_redraw() { 141 printf("*** console redraw ***\n"); 142 } 143 132 144 void script_console_clear() { 133 145 printf("*** clear console ***\n"); -
trunk/lib/ubasic/tokenizer.c
r106 r172 97 97 //{"shot", TOKENIZER_SHOOT}, // for compatibility 98 98 {"shoot", TOKENIZER_SHOOT}, 99 {"set_console_layout", TOKENIZER_SET_CONSOLE_LAYOUT}, 100 {"set_console_autoredraw", TOKENIZER_SET_CONSOLE_AUTOREDRAW}, 101 {"console_redraw", TOKENIZER_CONSOLE_REDRAW}, 99 102 {"sleep", TOKENIZER_SLEEP}, 100 103 -
trunk/lib/ubasic/tokenizer.h
r106 r172 91 91 TOKENIZER_RELEASE, 92 92 TOKENIZER_SHOOT, 93 TOKENIZER_SET_CONSOLE_LAYOUT, 94 TOKENIZER_SET_CONSOLE_AUTOREDRAW, 95 TOKENIZER_CONSOLE_REDRAW, 93 96 TOKENIZER_GET_TV96, 94 97 TOKENIZER_GET_USER_TV96, -
trunk/lib/ubasic/ubasic.c
r166 r172 1411 1411 1412 1412 /*---------------------------------------------------------------------------*/ 1413 static void set_console_layout(void) 1414 { 1415 int x1,y1,x2,y2; 1416 accept(TOKENIZER_SET_CONSOLE_LAYOUT); 1417 x1 = expr(); 1418 y1 = expr(); 1419 x2 = expr(); 1420 y2 = expr(); 1421 script_console_set_layout(x1,y1,x2,y2); 1422 accept_cr(); 1423 } 1424 /*---------------------------------------------------------------------------*/ 1425 static void set_console_autoredraw(void) 1426 { 1427 accept(TOKENIZER_SET_CONSOLE_AUTOREDRAW); 1428 script_console_set_autoredraw(expr()); 1429 accept_cr(); 1430 } 1431 /*---------------------------------------------------------------------------*/ 1432 static void console_redraw(void) 1433 { 1434 accept(TOKENIZER_CONSOLE_REDRAW); 1435 script_console_redraw(); 1436 accept_cr(); 1437 } 1438 /*---------------------------------------------------------------------------*/ 1413 1439 1414 1440 #ifdef INCLUDE_OLD_GET__SYNTAX … … 2248 2274 case TOKENIZER_SHOOT: 2249 2275 shoot_statement(); 2276 break; 2277 case TOKENIZER_SET_CONSOLE_LAYOUT: 2278 set_console_layout(); 2279 break; 2280 case TOKENIZER_SET_CONSOLE_AUTOREDRAW: 2281 set_console_autoredraw(); 2282 break; 2283 case TOKENIZER_CONSOLE_REDRAW: 2284 console_redraw(); 2250 2285 break; 2251 2286 #ifdef INCLUDE_OLD_GET__SYNTAX
Note: See TracChangeset
for help on using the changeset viewer.