Free Hero Mesh

Check-in [59dfac25ca]
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:Start to implement editing level strings (not finished yet)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 59dfac25ca1d809c12d11d8e42300a48a59a6ca8
User & Date: user on 2021-03-28 06:01:31
Other Links: manifest | tags
Context
2021-03-28
20:25
Complete implementing level strings in the level editor (I think) check-in: 51681082e0 user: user tags: trunk
06:01
Start to implement editing level strings (not finished yet) check-in: 59dfac25ca user: user tags: trunk
2021-03-27
23:21
Disable a part of the code which is currently unused. check-in: 95388f9377 user: user tags: trunk
Changes

Modified bindings.doc from [12900583cc] to [ab99235ee1].

120
121
122
123
124
125
126



127
128
129
130
131
132
133
  Display the class selection menu.

'^e'
  Edit the currently selected MRU values. (You can only edit the direction
  and the Misc values (1 to 3), not the class and image; to edit the class
  and image, use the class selection menu.)




'^u' <location>
  Add an object with the current MRU values to that location, even if
  there is already another object of the same class at that location.

'ex' <command>
  Export a level (given the operating system command to receive the
  exported data). See export.doc for details.







>
>
>







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
  Display the class selection menu.

'^e'
  Edit the currently selected MRU values. (You can only edit the direction
  and the Misc values (1 to 3), not the class and image; to edit the class
  and image, use the class selection menu.)

'^s'
  Display the list of level strings.

'^u' <location>
  Add an object with the current MRU values to that location, even if
  there is already another object of the same class at that location.

'ex' <command>
  Export a level (given the operating system command to receive the
  exported data). See export.doc for details.

Modified default.heromeshrc from [bcc7dad1c1] to [3ef6cce4af].

135
136
137
138
139
140
141

142
143
144
145
146
147
148
?.editKey.6: select 'mr',5;
?.editKey.7: select 'mr',6;
?.editKey.8: select 'mr',7;
?.editKey.9: select 'mr',8;
?.editKey.up: select 'mR',-1;
?.editKey.down: select 'mR',+1;
?.editKey.C: select 'lc',:level_code where :level_code=cast(:level_code as int);

?.editKey.F: with n(n) as (select 65 union all select n+1 h from n where h<=64*pfheight()+65) select '^a',n from n;
?.editKey.R: select 're',substr(:resize,1,instr(:resize,'x')-1),substr(:resize,instr(:resize,'x')+1) where length(:resize);
?.editKey.ctrl.N: ^N
?.editKey.ctrl.P: ^P
?.editKey.ctrl.Q: ^Q
?.editKey.ctrl.S: ^S
?.editKey.ctrl.T: ^T







>







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
?.editKey.6: select 'mr',5;
?.editKey.7: select 'mr',6;
?.editKey.8: select 'mr',7;
?.editKey.9: select 'mr',8;
?.editKey.up: select 'mR',-1;
?.editKey.down: select 'mR',+1;
?.editKey.C: select 'lc',:level_code where :level_code=cast(:level_code as int);
?.editKey.E: ^s
?.editKey.F: with n(n) as (select 65 union all select n+1 h from n where h<=64*pfheight()+65) select '^a',n from n;
?.editKey.R: select 're',substr(:resize,1,instr(:resize,'x')-1),substr(:resize,instr(:resize,'x')+1) where length(:resize);
?.editKey.ctrl.N: ^N
?.editKey.ctrl.P: ^P
?.editKey.ctrl.Q: ^Q
?.editKey.ctrl.S: ^S
?.editKey.ctrl.T: ^T

Modified edit.c from [dca0840b6e] to [b7508d9e96].

1259
1260
1261
1262
1263
1264
1265


















































































1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278



1279
1280
1281
1282
1283
1284
1285
  memmove(cp+1,cp,(s+sz+1)-cp);
  if(!o) memmove(cp+1,cp,(s+sz+1)-cp);
  *cp=31;
  cp[1]=i;
  c++;
  goto redraw;
}



















































































static int editor_command(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux) {
  int x,y;
  switch(cmd) {
    case '^a': // Add object (no duplicates)
      if(prev) return prev;
      add_object_at(number&63?:64,number/64?:64,mru+curmru,1);
      return 0;
    case '^c': // Select class/image
      class_image_select();
      return 0;
    case '^e': // Edit Misc/Dir of MRU slot
      mru_edit(mru+curmru);



      return 0;
    case '^u': // Add object (allow duplicates)
      if(prev) return prev;
      add_object_at(number&63?:64,number/64?:64,mru+curmru,0);
      return 0;
    case '^N': // New level
      if(level_nindex>0xFFFE) return 0;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>













>
>
>







1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
  memmove(cp+1,cp,(s+sz+1)-cp);
  if(!o) memmove(cp+1,cp,(s+sz+1)-cp);
  *cp=31;
  cp[1]=i;
  c++;
  goto redraw;
}

static int string_list(void) {
  char buf[18];
  SDL_Event ev;
  SDL_Rect r;
  int n=0;
  int scroll=0;
  int i,j;
  redraw:
  r.x=r.y=0;
  r.w=screen->w;
  r.h=screen->h;
  SDL_FillRect(screen,&r,0xF0);
  r.h=8;
  SDL_FillRect(screen,&r,0xF1);
  r.y=8;
  r.h=screen->h-8;
  scrollbar(&scroll,screen->h/8-1,nlevelstrings,0,&r);
  SDL_LockSurface(screen);
  draw_text(0,0,"Level Strings:   <INS> Add  <DEL> Delete  <SP> Edit  <RET> Pick  <F1> Preview  <ESC> Cancel",0xF1,0xFF);
  for(i=0;i<screen->h/8-1;i++) {
    j=i+scroll;
    if(j>=nlevelstrings) break;
    snprintf(buf,8,"%c%5d%c",n==j?'<':' ',j,n==j?'>':' ');
    draw_text(16,(i+1)<<3,buf,0xF0,0xFB);
    draw_text(80,(i+1)<<3,levelstrings[j],0xF0,0xF7);
  }
  SDL_UnlockSurface(screen);
  SDL_Flip(screen);
  while(SDL_WaitEvent(&ev)) {
    if(ev.type!=SDL_VIDEOEXPOSE && scrollbar(&scroll,screen->h/8-1,nlevelstrings,&ev,&r)) goto redraw;
    switch(ev.type) {
      case SDL_MOUSEMOTION:
        set_cursor(XC_draft_small);
        break;
      case SDL_KEYDOWN:
        switch(ev.key.keysym.sym) {
          case SDLK_0: case SDLK_KP0: n*=10; break;
          case SDLK_1: case SDLK_KP1: n=10*n+1; break;
          case SDLK_2: case SDLK_KP2: n=10*n+2; break;
          case SDLK_3: case SDLK_KP3: n=10*n+3; break;
          case SDLK_4: case SDLK_KP4: n=10*n+4; break;
          case SDLK_5: case SDLK_KP5: n=10*n+5; break;
          case SDLK_6: case SDLK_KP6: n=10*n+6; break;
          case SDLK_7: case SDLK_KP7: n=10*n+7; break;
          case SDLK_8: case SDLK_KP8: n=10*n+8; break;
          case SDLK_9: case SDLK_KP9: n=10*n+9; break;
          case SDLK_BACKSPACE: n/=10; break;
          case SDLK_ESCAPE: return -1;
          case SDLK_RETURN: case SDLK_KP_ENTER: if(n<nlevelstrings) return n;
          case SDLK_SPACE: edit_string(levelstrings+n); break;
          case SDLK_INSERT:
            if(nlevelstrings<0x2000) {
              levelstrings=realloc(levelstrings,(nlevelstrings+1)*sizeof(unsigned char*));
              if(!levelstrings) fatal("Allocation failed\n");
              levelstrings[n=nlevelstrings++]=strdup("");
              if(!levelstrings[n]) fatal("Allocation failed\n");
              edit_string(levelstrings+n);
            }
            break;
          case SDLK_DELETE:
            if(n>=nlevelstrings) break;
            if(n==nlevelstrings-1) {
              free(levelstrings[--nlevelstrings]);
            } else {
              //TODO
            }
            break;
          case SDLK_F1: if(nlevelstrings) modal_draw_popup(levelstrings[n]); set_cursor(XC_draft_small); break;
          case SDLK_UP: case SDLK_KP_MINUS: n--; break;
          case SDLK_DOWN: case SDLK_KP_PLUS: n++; break;
        }
        if(n<=0) n=0; else if(n>=nlevelstrings) n=nlevelstrings-1;
        goto redraw;
      case SDL_VIDEOEXPOSE:
        goto redraw;
      case SDL_QUIT:
        exit(0);
        return -1;
    }
  }
}

static int editor_command(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux) {
  int x,y;
  switch(cmd) {
    case '^a': // Add object (no duplicates)
      if(prev) return prev;
      add_object_at(number&63?:64,number/64?:64,mru+curmru,1);
      return 0;
    case '^c': // Select class/image
      class_image_select();
      return 0;
    case '^e': // Edit Misc/Dir of MRU slot
      mru_edit(mru+curmru);
      return 0;
    case '^s': // String list/edit
      string_list();
      return 0;
    case '^u': // Add object (allow duplicates)
      if(prev) return prev;
      add_object_at(number&63?:64,number/64?:64,mru+curmru,0);
      return 0;
    case '^N': // New level
      if(level_nindex>0xFFFE) return 0;