Free Hero Mesh

Check-in [c1b51c9521]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Add the global examine command
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c1b51c952140c90821e3b7bcb35f324cc1746967
User & Date: user on 2021-03-06 05:22:07
Other Links: manifest | tags
Context
2021-03-06
06:04
Add level exporting. (Importing is not implemented yet.) check-in: dd82c6e9b5 user: user tags: trunk
05:22
Add the global examine command check-in: c1b51c9521 user: user tags: trunk
04:52
Correct a mistake in the OBJECTS virtual table causing it to sometimes miss one object check-in: ea3817b085 user: user tags: trunk
Changes

Modified bindings.doc from [1946559283] to [6cec4c2c09].

73
74
75
76
77
78
79



80
81
82
83
84
85
86
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89







+
+
+








'^T'
  Display the level title popup.

'^d' <location>
  Display the pop-up help text of the object at the location.

'^g'
  Display values of global variables.

'^o' <location>
  List objects at the specified coordinates, to examine their values.

'^s'
  Toggle solution replay.

'mi' <command>

Modified default.heromeshrc from [f4fd84468a] to [0a5a74d628].

120
121
122
123
124
125
126

127
128
129
130
131
132
133
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134







+







?.gameKey.shift.f3: -100
?.gameKey.shift.f4: -1000
?.gameKey.f5: ^M
?.gameKey.f6: ^<
?.gameKey.f7: ^>
?.gameKey.f8: ^s
?.gameKey.tab: ^I
?.gameKey.alt.G: ^g

! Editor key bindings
?.editKey.1: select 'mr',0;
?.editKey.2: select 'mr',1;
?.editKey.3: select 'mr',2;
?.editKey.4: select 'mr',3;
?.editKey.5: select 'mr',4;

Modified game.c from [f0b75ac91a] to [03a7e35a75].

298
299
300
301
302
303
304



305
306
307
308
309
310
311
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314







+
+
+







      break;
    case TY_SOUND: case TY_USOUND:
      draw_text(200,y,"<Sound>",0xF0,0xF6);
      break;
    case TY_MARK:
      draw_text(200,y,"<Mark>",0xF0,0xF3);
      break;
    case TY_ARRAY:
      draw_text(200,y,"<Array>",0xF0,0xF9);
      break;
    default:
      snprintf(buf,80,"<%lu:%lu>",(long)v.u,(long)v.t);
      draw_text(200,y,buf,0xF0,0xFA);
      i=strlen(buf)*8+208;
      if(v.u<nobjects && objects[v.u] && objects[v.u]->generation==v.t) {
        snprintf(buf,80,"@ (%d,%d)",objects[v.u]->x,objects[v.u]->y);
        draw_text(i,y,buf,0xF0,0xF2);
404
405
406
407
408
409
410






















































411
412
413
414
415
416
417
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







  exam_hardsharp("Hardness:",25,o->hard);
  exam_hardsharp("Sharpness:",26,o->sharp);
  while(sqlite3_step(st)==SQLITE_ROW) {
    i=sqlite3_column_int(st,1);
    exam_value(sqlite3_column_text(st,0),i+28,o->uservars[i]);
  }
  quiz:
  sqlite3_reset(st);
  SDL_UnlockSurface(screen);
  SDL_Flip(screen);
  while(SDL_WaitEvent(&ev)) switch(ev.type) {
    case SDL_KEYDOWN:
      switch(ev.key.keysym.sym) {
        case SDLK_ESCAPE: case SDLK_RETURN: case SDLK_KP_ENTER: sqlite3_finalize(st); return;
        case SDLK_UP: if(exam_scroll) exam_scroll--; break;
        case SDLK_DOWN: exam_scroll++; break;
        case SDLK_HOME: exam_scroll=0; break;
        case SDLK_PAGEUP: exam_scroll-=screen->h/8; if(exam_scroll<0) exam_scroll=0; break;
        case SDLK_PAGEDOWN: exam_scroll+=screen->h/8; break;
      }
      goto redraw;
    case SDL_MOUSEMOTION:
      if(ev.motion.y!=y && ev.motion.y<screen->h) {
        SDL_LockSurface(screen);
        draw_back_line(y,0xF0);
        draw_back_line(y=ev.motion.y,0xF1);
        SDL_UnlockSurface(screen);
        SDL_Flip(screen);
      }
      break;
    case SDL_VIDEOEXPOSE:
      goto redraw;
    case SDL_QUIT:
      exit(0);
      break;
  }
}

static void global_examine(void) {
  sqlite3_stmt*st;
  SDL_Event ev;
  SDL_Rect r;
  int i,y;
  y=0;
  i=sqlite3_prepare_v2(userdb,"SELECT '@'||`NAME`,`ID` FROM `VARIABLES` WHERE `ID` BETWEEN 0x0000 AND 0xFFFF ORDER BY `ID`",-1,&st,0);
  if(i) fatal("SQL error (%d): %s",i,sqlite3_errmsg(userdb));
  exam_scroll=0;
  redraw:
  set_cursor(XC_arrow);
  r.x=r.y=0;
  r.w=screen->w;
  r.h=screen->h;
  SDL_FillRect(screen,&r,0xF0);
  SDL_LockSurface(screen);
  exam_value("MoveNumber:",0,NVALUE(move_number));
  exam_value("LevelStrings:",1,NVALUE(nlevelstrings));
  exam_value("Generation:",2,NVALUE(generation_number));
  while(sqlite3_step(st)==SQLITE_ROW) {
    i=sqlite3_column_int(st,1);
    exam_value(sqlite3_column_text(st,0),i+4,globals[i]);
  }
  sqlite3_reset(st);
  SDL_UnlockSurface(screen);
  SDL_Flip(screen);
  while(SDL_WaitEvent(&ev)) switch(ev.type) {
    case SDL_KEYDOWN:
      switch(ev.key.keysym.sym) {
        case SDLK_ESCAPE: case SDLK_RETURN: case SDLK_KP_ENTER: sqlite3_finalize(st); return;
619
620
621
622
623
624
625



626
627
628
629
630
631
632
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692







+
+
+







    case '^Q': // Quit
      return -1;
    case '^T': // Show title
      modal_draw_popup(level_title);
      return prev;
    case '^d': // Describe object
      describe_at(number-65);
      return prev;
    case '^g': // Display global variables
      global_examine();
      return prev;
    case '^o': // List objects
      list_objects_at(number-65);
      return prev;
    case '^s': // Toggle solution replay
      if(replay_count) save_replay();
      solution_replay^=1;

Modified picture.c from [207559e683] to [9877da8adc].

785
786
787
788
789
790
791

792
793
794
795
796

797
798
799
800
801
802
803
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805







+





+







      break;
  }
  SDL_UnlockSurface(screen);
}

int modal_draw_popup(const unsigned char*txt) {
  SDL_Event ev;
#if 0
  SDL_Rect r;
  r.x=r.y=0;
  r.w=screen->w;
  r.h=4;
  SDL_FillRect(screen,&r,0xFE);
#endif
  set_cursor(XC_iron_cross);
  redraw:
  draw_popup(txt);
  SDL_Flip(screen);
  while(SDL_WaitEvent(&ev)) switch(ev.type) {
    case SDL_QUIT:
      SDL_PushEvent(&ev);