Overview
Comment: | Implement the inventory display |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0ba0570c8c4fe38aa60f89bcea38374e |
User & Date: | user on 2021-01-04 07:15:18 |
Other Links: | manifest | tags |
Context
2021-01-05
| ||
04:36 | Start making the key code icons check-in: 2d56b51997 user: user tags: trunk | |
2021-01-04
| ||
07:15 | Implement the inventory display check-in: 0ba0570c8c user: user tags: trunk | |
06:29 | Improvement of comments in heromesh.h check-in: 7b83e02ee7 user: user tags: trunk | |
Changes
Modified bindings.doc from [6ef576a661] to [2eb92fb80c].
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | '^<' Rewind to mark. '^>' Replay to mark. '^M' Set the replay mark position. '^T' Display the level title popup. '^d' <location> | > > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | '^<' Rewind to mark. '^>' Replay to mark. '^I' Toggle the inventory/move-list display. '^M' Set the replay mark position. '^T' Display the level title popup. '^d' <location> |
︙ | ︙ |
Modified class.c from [33b921b461] to [a9810d154f].
︙ | ︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | Value initglobals[0x800]; Class*classes[0x4000]; const char*messages[0x4000]; Uint16 functions[0x4000]; int max_animation=32; Sint32 max_volume=10000; Uint8 back_color=1; char**stringpool; AnimationSlot anim_slot[8]; #define HASH_SIZE 8888 #define LOCAL_HASH_SIZE 5555 typedef struct { Uint16 id; | > | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | Value initglobals[0x800]; Class*classes[0x4000]; const char*messages[0x4000]; Uint16 functions[0x4000]; int max_animation=32; Sint32 max_volume=10000; Uint8 back_color=1; Uint8 inv_back_color=9; char**stringpool; AnimationSlot anim_slot[8]; #define HASH_SIZE 8888 #define LOCAL_HASH_SIZE 5555 typedef struct { Uint16 id; |
︙ | ︙ | |||
1611 1612 1613 1614 1615 1616 1617 | nxttok(); if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n"); break; case OP_BACKGROUND: nxttok(); if(tokent!=TF_INT) ParseError("Number expected\n"); if(tokenv&~255) ParseError("Background color out of range\n"); | > > > > | | > | 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 | nxttok(); if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n"); break; case OP_BACKGROUND: nxttok(); if(tokent!=TF_INT) ParseError("Number expected\n"); if(tokenv&~255) ParseError("Background color out of range\n"); back_color=inv_back_color=tokenv; nxttok(); if(tokent==TF_INT) { if(tokenv&~255) ParseError("Background color out of range\n"); inv_back_color=tokenv; nxttok(); } if(tokent!=TF_CLOSE) ParseError("Expected close parenthesis\n"); break; case OP_ANIMATE: nxttok(); if(tokent!=TF_INT) ParseError("Number expected\n"); if(tokenv<1 || tokenv>256) ParseError("Number of max animation steps out of range\n"); max_animation=tokenv; |
︙ | ︙ |
Modified class.doc from [f0b38ad4c2] to [3662bf9dd0].
︙ | ︙ | |||
190 191 192 193 194 195 196 | === Global definitions === These are the global definitions in the class definition file. (Animate <limit>) Set the limit for logical animations, from 1 to 255. The default is 32. | | | > > | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | === Global definitions === These are the global definitions in the class definition file. (Animate <limit>) Set the limit for logical animations, from 1 to 255. The default is 32. (Background <number> [<number>]) Set the background colour, from 0 to 255. The default value is 1. You can optionally specify a second number, which is the background colour for the inventory; if not specified, uses the same colour for both. (Synchronize <slot> <length> <speed>) Define an animation slot for synchronized animation. The slot number can be 0 to 7, the length is the number of images in the sequence, and the speed is the number of centiseconds between frames. (Volume <number>) |
︙ | ︙ |
Modified game.c from [ba2cd038c4] to [271271dcf7].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | Uint8*replay_list; Uint16 replay_size,replay_count,replay_pos,replay_mark; static volatile Uint8 timerflag; static int exam_scroll; static Uint8*inputs; static int inputs_size,inputs_count; static void redraw_game(void) { char buf[32]; SDL_Rect r; int x,y; r.x=r.y=0; r.h=screen->h; | > > > > > > > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | Uint8*replay_list; Uint16 replay_size,replay_count,replay_pos,replay_mark; static volatile Uint8 timerflag; static int exam_scroll; static Uint8*inputs; static int inputs_size,inputs_count; static Uint8 side_mode=255; static void setup_game(void) { const char*v; optionquery[1]=Q_showInventory; v=xrm_get_resource(resourcedb,optionquery,optionquery,2)?:""; side_mode=boolxrm(v,1); } static void redraw_game(void) { char buf[32]; SDL_Rect r; int x,y; r.x=r.y=0; r.h=screen->h; |
︙ | ︙ | |||
73 74 75 76 77 78 79 | draw_text(8,32,buf,0xF0,0xFD); draw_text(24,32,"x",0xF0,0xF5); x=x>=left_margin?(x-left_margin)/picture_size+1:0; y=y/picture_size+1; if(x>0 && y>0 && x<=pfwidth && y<=pfheight) snprintf(buf,8,"(%2d,%2d)",x,y); else strcpy(buf," "); draw_text(0,40,buf,0xF0,0xF1); | > > > > > > > > > > | > > > > > > > > > > > > > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | draw_text(8,32,buf,0xF0,0xFD); draw_text(24,32,"x",0xF0,0xF5); x=x>=left_margin?(x-left_margin)/picture_size+1:0; y=y/picture_size+1; if(x>0 && y>0 && x<=pfwidth && y<=pfheight) snprintf(buf,8,"(%2d,%2d)",x,y); else strcpy(buf," "); draw_text(0,40,buf,0xF0,0xF1); if(side_mode) { // Inventory x=20-(left_margin-picture_size)/8; if(x>19) x=19; if(x<0) x=0; for(y=0;y<ninventory;y++) { if(y*picture_size+60>=screen->h) break; snprintf(buf,22,"%20d",inventory[y].value); draw_text(picture_size,y*picture_size+52,buf+x,0xF8,0xFE); } SDL_UnlockSurface(screen); r.x=0; r.y=52; r.w=picture_size; r.h=screen->h-52; SDL_FillRect(screen,&r,inv_back_color); for(y=0;y<ninventory;y++) { if(y*picture_size+60>=screen->h) break; if(classes[inventory[y].class]->nimages<inventory[y].image) continue; draw_picture(0,y*picture_size+52,classes[inventory[y].class]->images[inventory[y].image]&0x7FFF); } } else { // Move list SDL_UnlockSurface(screen); } if(quiz_text) draw_popup(quiz_text); SDL_Flip(screen); set_cursor(XC_arrow); } static void continue_animation(void) { Uint32 n=firstobj; |
︙ | ︙ | |||
440 441 442 443 444 445 446 447 448 449 450 451 452 453 | goto restart; case '^>': // Replay to mark inputs_count=0; number=replay_mark-replay_pos; goto replay; case '^E': // Edit return -2; case '^M': // Mark replay position replay_mark=replay_pos+inputs_count; return prev; case '^Q': // Quit return -1; case '^T': // Show title modal_draw_popup(level_title); | > > > | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | goto restart; case '^>': // Replay to mark inputs_count=0; number=replay_mark-replay_pos; goto replay; case '^E': // Edit return -2; case '^I': // Toggle inventory display side_mode^=1; return prev; case '^M': // Mark replay position replay_mark=replay_pos+inputs_count; return prev; case '^Q': // Quit return -1; case '^T': // Show title modal_draw_popup(level_title); |
︙ | ︙ | |||
512 513 514 515 516 517 518 519 520 521 522 523 524 525 | } } void run_game(void) { int i; SDL_Event ev; set_caption(); begin_level(level_id); redraw_game(); timerflag=0; SDL_SetTimer(10,timer_callback); while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_VIDEOEXPOSE: | > | 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | } } void run_game(void) { int i; SDL_Event ev; set_caption(); if(side_mode==255) setup_game(); begin_level(level_id); redraw_game(); timerflag=0; SDL_SetTimer(10,timer_callback); while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_VIDEOEXPOSE: |
︙ | ︙ |
Modified heromesh.h from [512c09304e] to [4bcb7663f0].
︙ | ︙ | |||
148 149 150 151 152 153 154 | extern Value initglobals[0x800]; extern Class*classes[0x4000]; // 0 isn't a real class extern const char*messages[0x4000]; // index is 256 less than message number extern Uint16 functions[0x4000]; extern int max_animation; // max steps in animation queue (default 32) extern Sint32 max_volume; // max total volume to allow moving diagonally (default 10000) | | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | extern Value initglobals[0x800]; extern Class*classes[0x4000]; // 0 isn't a real class extern const char*messages[0x4000]; // index is 256 less than message number extern Uint16 functions[0x4000]; extern int max_animation; // max steps in animation queue (default 32) extern Sint32 max_volume; // max total volume to allow moving diagonally (default 10000) extern Uint8 back_color,inv_back_color; extern char**stringpool; extern AnimationSlot anim_slot[8]; Uint16 get_message_ptr(int c,int m); void load_classes(void); // == bindings == |
︙ | ︙ |
Modified quarks from [3b8f040017] to [1be78c1f08].
︙ | ︙ | |||
211 212 213 214 215 216 217 218 | ! Miscellaneous level tracePrefix stackProtection maxObjects traceAll traceObject | > | 211 212 213 214 215 216 217 218 219 | ! Miscellaneous level tracePrefix stackProtection maxObjects traceAll traceObject showInventory |
Modified quarks.h from [1834c51d24] to [eb6ffb657a].
︙ | ︙ | |||
176 177 178 179 180 181 182 183 184 185 186 187 188 189 | #define Q_sqlPowerSafe 177 #define Q_level 178 #define Q_tracePrefix 179 #define Q_stackProtection 180 #define Q_maxObjects 181 #define Q_traceAll 182 #define Q_traceObject 183 static const char*const global_quarks[]={ "screenWidth", "screenHeight", "margin", "palette", "popupColors", "imageSize", | > | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | #define Q_sqlPowerSafe 177 #define Q_level 178 #define Q_tracePrefix 179 #define Q_stackProtection 180 #define Q_maxObjects 181 #define Q_traceAll 182 #define Q_traceObject 183 #define Q_showInventory 184 static const char*const global_quarks[]={ "screenWidth", "screenHeight", "margin", "palette", "popupColors", "imageSize", |
︙ | ︙ | |||
359 360 361 362 363 364 365 366 367 368 369 370 371 372 | "sqlPowerSafe", "level", "tracePrefix", "stackProtection", "maxObjects", "traceAll", "traceObject", 0}; #ifdef HEROMESH_BINDINGS static const SDLKey quark_to_key[Q_undo+1-Q_backspace]={ SDLK_BACKSPACE, SDLK_TAB, SDLK_CLEAR, SDLK_RETURN, | > | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | "sqlPowerSafe", "level", "tracePrefix", "stackProtection", "maxObjects", "traceAll", "traceObject", "showInventory", 0}; #ifdef HEROMESH_BINDINGS static const SDLKey quark_to_key[Q_undo+1-Q_backspace]={ SDLK_BACKSPACE, SDLK_TAB, SDLK_CLEAR, SDLK_RETURN, |
︙ | ︙ |