Overview
Comment: | Implement properly (hopefully) the mouse button down event in edit.c and game.c |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8119f365c2904a398525c322b6d8e2c4 |
User & Date: | user on 2020-11-16 04:51:13 |
Other Links: | manifest | tags |
Context
2020-11-16
| ||
04:55 | Correct the license check-in: f14e1a7d44 user: user tags: trunk | |
04:51 | Implement properly (hopefully) the mouse button down event in edit.c and game.c check-in: 8119f365c2 user: user tags: trunk | |
2020-10-20
| ||
23:21 | Add game.c file (not implemented much) check-in: 9d982f0655 user: user tags: trunk | |
Changes
Modified edit.c from [3d325ead70] to [9c9daca4d1].
︙ | ︙ | |||
344 345 346 347 348 349 350 351 | set_cursor(ev.motion.x<left_margin?XC_arrow:XC_tcross); show_mouse_xy(&ev); break; case SDL_MOUSEBUTTONDOWN: if(ev.button.x<left_margin) { break; } | > > > < > | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | set_cursor(ev.motion.x<left_margin?XC_arrow:XC_tcross); show_mouse_xy(&ev); break; case SDL_MOUSEBUTTONDOWN: if(ev.button.x<left_margin) { break; } else { i=exec_key_binding(&ev,1,(ev.button.x-left_margin)/picture_size+1,ev.button.y/picture_size+1,editor_command,0); goto command; } case SDL_KEYDOWN: i=exec_key_binding(&ev,1,0,0,editor_command,0); command: if(i==-1) exit(0); if(i==-2) { main_options['e']=0; return; } redraw_editor(); break; |
︙ | ︙ |
Modified exec.c from [5cd8b5f27b] to [47586b49e3].
︙ | ︙ | |||
216 217 218 219 220 221 222 223 224 225 226 227 228 229 | nobjects=0; free(objects); objects=0; gameover=0; } const char*execute_turn(int key) { if(setjmp(my_env)) return my_error; changed=0; key_ignored=0; lastimage_processing=0; vstackptr=0; if(key_ignored && changed) return "Invalid use of IgnoreKey"; | > | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | nobjects=0; free(objects); objects=0; gameover=0; } const char*execute_turn(int key) { // Set key=0 for initialization if(setjmp(my_env)) return my_error; changed=0; key_ignored=0; lastimage_processing=0; vstackptr=0; if(key_ignored && changed) return "Invalid use of IgnoreKey"; |
︙ | ︙ |
Modified game.c from [39a9a6de05] to [adfd260a0a].
︙ | ︙ | |||
113 114 115 116 117 118 119 120 | case SDL_QUIT: exit(0); break; case SDL_MOUSEBUTTONDOWN: if(ev.button.x<left_margin) { break; } | > > > < > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | case SDL_QUIT: exit(0); break; case SDL_MOUSEBUTTONDOWN: if(ev.button.x<left_margin) { break; } else { i=exec_key_binding(&ev,0,(ev.button.x-left_margin)/picture_size+1,ev.button.y/picture_size+1,game_command,0); goto command; } case SDL_KEYDOWN: i=exec_key_binding(&ev,0,0,0,game_command,0); command: if(i==-1) exit(0); if(i==-2) { main_options['e']=1; return; } redraw_game(); break; |
︙ | ︙ |
Modified picture.c from [0cf3fc6eed] to [66da19aea7].
︙ | ︙ | |||
196 197 198 199 200 201 202 203 204 205 206 207 208 209 | draw_text(0,8,t,0xF1,0xFF); draw_text(n<<3,8,"\xB1",0xF1,0xFB); SDL_UnlockSurface(screen); SDL_Flip(screen); } } } static Uint16 decide_picture_size(int nwantsize,const Uint8*wantsize,const Uint16*havesize,int n) { int i,j; if(!nwantsize) fatal("Unable to determine what picture size is wanted\n"); for(i=0;i<nwantsize;i++) if(havesize[j=wantsize[i]]==n) return j; for(i=*wantsize;i;--i) if(havesize[i]) return i; fatal("Unable to determine what picture size is wanted\n"); | > > > > > > > > > > > > > > > > > > > > > | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | draw_text(0,8,t,0xF1,0xFF); draw_text(n<<3,8,"\xB1",0xF1,0xFB); SDL_UnlockSurface(screen); SDL_Flip(screen); } } } void screen_message(const char*txt) { SDL_Rect r; SDL_Event ev; set_cursor(XC_iron_cross); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_QUIT: SDL_PushEvent(&ev); return; case SDL_KEYDOWN: return; case SDL_MOUSEBUTTONDOWN: return; } } } static Uint16 decide_picture_size(int nwantsize,const Uint8*wantsize,const Uint16*havesize,int n) { int i,j; if(!nwantsize) fatal("Unable to determine what picture size is wanted\n"); for(i=0;i<nwantsize;i++) if(havesize[j=wantsize[i]]==n) return j; for(i=*wantsize;i;--i) if(havesize[i]) return i; fatal("Unable to determine what picture size is wanted\n"); |
︙ | ︙ |