… | |
… | |
171 | } maptex; |
171 | } maptex; |
172 | |
172 | |
173 | typedef struct { |
173 | typedef struct { |
174 | uint16_t darkness; |
174 | uint16_t darkness; |
175 | mapface face[3]; |
175 | mapface face[3]; |
176 | uint8_t stat_hp; |
176 | uint8_t stat_width, stat_hp; |
177 | } mapcell; |
177 | } mapcell; |
178 | |
178 | |
179 | typedef struct { |
179 | typedef struct { |
180 | int32_t c0, c1; |
180 | int32_t c0, c1; |
181 | mapcell *col; |
181 | mapcell *col; |
… | |
… | |
1305 | do |
1305 | do |
1306 | { |
1306 | { |
1307 | ext = *data++; |
1307 | ext = *data++; |
1308 | cmd = ext & 0x3f; |
1308 | cmd = ext & 0x3f; |
1309 | |
1309 | |
1310 | if (ext < 4) |
1310 | if (cmd < 4) |
1311 | cell->darkness = 255 - ext * 64 + 1; |
1311 | cell->darkness = 255 - ext * 64 + 1; |
1312 | else if (ext == 5) // health |
1312 | else if (cmd == 5) // health |
|
|
1313 | { |
|
|
1314 | cell->stat_width = 1; |
1313 | cell->stat_hp = *data++; |
1315 | cell->stat_hp = *data++; |
|
|
1316 | } |
|
|
1317 | else if (cmd == 6) // monster width |
|
|
1318 | cell->stat_width = *data++ + 1; |
1314 | else if (ext & 0x40) // unknown, multibyte => skip |
1319 | else if (ext & 0x40) // unknown, multibyte => skip |
1315 | data += *data + 1; |
1320 | data += *data + 1; |
|
|
1321 | else |
|
|
1322 | data++; |
1316 | } |
1323 | } |
1317 | while (cmd & 0x80); |
1324 | while (ext & 0x80); |
1318 | } |
1325 | } |
1319 | else |
1326 | else |
1320 | cell->darkness = *data++ + 1; |
1327 | cell->darkness = *data++ + 1; |
1321 | } |
1328 | } |
1322 | |
1329 | |
… | |
… | |
1473 | } |
1480 | } |
1474 | |
1481 | |
1475 | glEnd (); |
1482 | glEnd (); |
1476 | |
1483 | |
1477 | glDisable (GL_TEXTURE_2D); |
1484 | glDisable (GL_TEXTURE_2D); |
1478 | glDisable (GL_BLEND); |
|
|
1479 | |
1485 | |
1480 | // top layer: overlays such as the health bar |
1486 | // top layer: overlays such as the health bar |
1481 | for (y = 0; y < sh; y++) |
1487 | for (y = 0; y < sh; y++) |
1482 | if (0 <= y + vy && y + vy < self->rows) |
1488 | if (0 <= y + vy && y + vy < self->rows) |
1483 | { |
1489 | { |
… | |
… | |
1491 | int px = x * 32; |
1497 | int px = x * 32; |
1492 | int py = y * 32; |
1498 | int py = y * 32; |
1493 | |
1499 | |
1494 | if (cell->stat_hp) |
1500 | if (cell->stat_hp) |
1495 | { |
1501 | { |
1496 | int width = sh / 28 + 1; |
1502 | int width = cell->stat_width * 32; |
|
|
1503 | int thick = sh / 28 + 1 + cell->stat_width; |
1497 | |
1504 | |
1498 | glColor3ub (0, 0, 0); |
1505 | glColor4ub (0, 0, 0, 223); |
1499 | glRectf (px + 1, py, px + 31, py + width + 2); |
1506 | glRectf (px + 1, py, |
|
|
1507 | px + width - 1, py + thick + 2); |
1500 | |
1508 | |
1501 | glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); |
1509 | glColor4ub (cell->stat_hp, 255 - cell->stat_hp, 0, 223); |
1502 | glRectf (px + 2, py + 1, px + 30 - cell->stat_hp * 28 / 255, py + width + 1); |
1510 | glRectf (px + 2, |
|
|
1511 | py + 1, |
|
|
1512 | px + width - 2 - cell->stat_hp * (width - 4) / 255, py + thick + 1); |
1503 | } |
1513 | } |
1504 | } |
1514 | } |
1505 | } |
1515 | } |
|
|
1516 | |
|
|
1517 | glDisable (GL_BLEND); |
1506 | } |
1518 | } |
1507 | |
1519 | |
1508 | void |
1520 | void |
1509 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1521 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1510 | CODE: |
1522 | CODE: |