Mapster32: improve 2d mode sprite label display. I want to test this further, so this is marked as DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@5289 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2015-07-10 07:56:48 +00:00
parent bd4917f7e1
commit 253f0b8771
5 changed files with 109 additions and 79 deletions

View file

@ -262,10 +262,11 @@ extern void showsectordata(int16_t sectnum, int16_t small);
extern void showwalldata(int16_t wallnum, int16_t small); extern void showwalldata(int16_t wallnum, int16_t small);
extern void showspritedata(int16_t spritenum, int16_t small); extern void showspritedata(int16_t spritenum, int16_t small);
extern void drawsmallabel(const char *text, char col, char backcol, int32_t dax, int32_t day, int32_t daz); extern void drawsmallabel(const char *text, char col, char backcol, char border, int32_t dax, int32_t day, int32_t daz);
extern int32_t whitecol; extern int32_t whitecol;
extern int32_t circlewall; extern int32_t circlewall;
extern int32_t searchlock;
int32_t loadsetup(const char *fn); // from config.c int32_t loadsetup(const char *fn); // from config.c
int32_t writesetup(const char *fn); // from config.c int32_t writesetup(const char *fn); // from config.c

View file

@ -176,6 +176,7 @@ static int32_t mousx, mousy;
int16_t prefixtiles[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int16_t prefixtiles[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
uint8_t hlsectorbitmap[MAXSECTORS>>3]; // show2dsector is already taken... uint8_t hlsectorbitmap[MAXSECTORS>>3]; // show2dsector is already taken...
static int32_t minhlsectorfloorz, numhlsecwalls; static int32_t minhlsectorfloorz, numhlsecwalls;
int32_t searchlock = 0;
// used for: // used for:
// - hl_all_bunch_sectors_p // - hl_all_bunch_sectors_p
@ -1570,7 +1571,7 @@ static inline void drawline16base(int32_t bx, int32_t by, int32_t x1, int32_t y1
drawline16(bx+x1, by+y1, bx+x2, by+y2, col); drawline16(bx+x1, by+y1, bx+x2, by+y2, col);
} }
void drawsmallabel(const char *text, char col, char backcol, int32_t dax, int32_t day, int32_t daz) void drawsmallabel(const char *text, char col, char backcol, char border, int32_t dax, int32_t day, int32_t daz)
{ {
int32_t x1, y1, x2, y2; int32_t x1, y1, x2, y2;
@ -1583,9 +1584,21 @@ void drawsmallabel(const char *text, char col, char backcol, int32_t dax, int32_
x2 = x1 + (Bstrlen(text)<<2)+2; x2 = x1 + (Bstrlen(text)<<2)+2;
y2 = y1 + 7; y2 = y1 + 7;
if ((x1 > 3) && (x2 < xdim) && (y1 > 1) && (y2 < ydim16)) int f = mulscale8(x2-x1, zoom);
if ((x1 > -f) && (x2 < xdim+f) && (y1 > -f) && (y2 < ydim16+f))
{ {
printext16(x1,y1, col,backcol, text,1); printext16(x1,y1, col,backcol, text,1);
drawline16(x1-2, y1-2, x2-2, y1-2, border);
drawline16(x1-2, y2+2, x2-2, y2+2, border);
drawline16(x1-2, y1-1, x2-2, y1-1, border);
drawline16(x1-2, y2+1, x2-2, y2+1, border);
drawline16(x1-3, y1-1, x1-3, y2+1, border);
drawline16(x2-1, y1-1, x2-1, y2+1, border);
drawline16(x1-1,y1-1, x2-3,y1-1, backcol); drawline16(x1-1,y1-1, x2-3,y1-1, backcol);
drawline16(x1-1,y2+1, x2-3,y2+1, backcol); drawline16(x1-1,y2+1, x2-3,y2+1, backcol);
@ -3237,6 +3250,29 @@ static void isc_transform(int32_t *x, int32_t *y)
} }
} }
static void drawspritelabel(int i)
{
const char *dabuffer = CallExtGetSpriteCaption(i);
if (dabuffer[0] != 0)
{
int const blocking = (sprite[i].cstat & 1);
int col = spritecol2d[sprite[i].picnum][0] ? editorcolors[spritecol2d[sprite[i].picnum][0]] : getspritecol(i);
if (col == -1)
col = editorcolors[3];
if ((i == pointhighlight - 16384) && (totalclock & 32))
col += 4;
if (sprite[i].sectnum < 0)
col = editorcolors[4]; // red
drawsmallabel(dabuffer, editorcolors[0], col, /*blocking ? editorcolors[5] :*/ col - 3,
sprite[i].x, sprite[i].y, sprite[i].z);
}
}
#define EDITING_MAP_P() (newnumwalls>=0 || joinsector[0]>=0 || circlewall>=0 || (bstatus&1) || isc.active) #define EDITING_MAP_P() (newnumwalls>=0 || joinsector[0]>=0 || circlewall>=0 || (bstatus&1) || isc.active)
#define HLMEMBERX(Hl, Member) (*(((Hl)&16384) ? &sprite[(Hl)&16383].Member : &wall[Hl].Member)) #define HLMEMBERX(Hl, Member) (*(((Hl)&16384) ? &sprite[(Hl)&16383].Member : &wall[Hl].Member))
@ -3502,8 +3538,7 @@ void overheadeditor(void)
get_sectors_center(&secshort, 1, &dax, &day); get_sectors_center(&secshort, 1, &dax, &day);
drawsmallabel(dabuffer, editorcolors[0], editorcolors[7], drawsmallabel(dabuffer, editorcolors[0], editorcolors[7], editorcolors[7] - 3, dax, day, getflorzofslope(i,dax,day));
dax, day, getflorzofslope(i,dax,day));
} }
} }
@ -3543,8 +3578,7 @@ void overheadeditor(void)
dax = (wal->x+wall[wal->point2].x)>>1; dax = (wal->x+wall[wal->point2].x)>>1;
day = (wal->y+wall[wal->point2].y)>>1; day = (wal->y+wall[wal->point2].y)>>1;
drawsmallabel(dabuffer, editorcolors[0], editorcolors[31], drawsmallabel(dabuffer, editorcolors[0], editorcolors[31], editorcolors[31] - 3, dax, day, (i >= numwalls || j<0) ? 0 : getflorzofslope(j, dax,day));
dax, day, (i >= numwalls || j<0) ? 0 : getflorzofslope(j, dax,day));
} }
} }
@ -3568,39 +3602,11 @@ void overheadeditor(void)
if ((!m32_sideview || !alwaysshowgray) && sprite[i].sectnum >= 0) if ((!m32_sideview || !alwaysshowgray) && sprite[i].sectnum >= 0)
YAX_SKIPSECTOR(sprite[i].sectnum); YAX_SKIPSECTOR(sprite[i].sectnum);
dabuffer = CallExtGetSpriteCaption(i); drawspritelabel(i);
if (dabuffer[0] != 0)
{
/*
int32_t blocking = (sprite[i].cstat&1);
col = 3 + 2*blocking;
if (spritecol2d[sprite[i].picnum][blocking])
col = spritecol2d[sprite[i].picnum][blocking];
*/
if (sprite[i].sectnum < 0)
col = editorcolors[4]; // red
else
{
if (spritecol2d[sprite[i].picnum][0])
col = editorcolors[spritecol2d[sprite[i].picnum][0]];
else
{
col = getspritecol(i);
if (col == -1)
col = editorcolors[3];
}
}
if ((i == pointhighlight-16384) && (totalclock & 32))
col += 4;
drawsmallabel(dabuffer, editorcolors[0], col,
sprite[i].x, sprite[i].y, sprite[i].z);
}
} }
if (pointhighlight & 16384)
drawspritelabel(pointhighlight - 16384);
} }
} }
@ -3784,7 +3790,7 @@ void overheadeditor(void)
drawline16(0,searchy, 8,searchy, editorcolors[15]); drawline16(0,searchy, 8,searchy, editorcolors[15]);
// 2d3d mode // 2d3d mode
if (m32_2d3dmode) if (m32_2d3dmode && xdimgame == xdim2d && ydimgame == ydim2d)
{ {
int bakrendmode = rendmode; int bakrendmode = rendmode;
vec2_t bdim ={ xdim, ydim }; vec2_t bdim ={ xdim, ydim };
@ -3825,7 +3831,7 @@ void overheadeditor(void)
if (!m32_is2d3dmode()) if (!m32_is2d3dmode())
{ {
////// draw mouse pointer ////// draw mouse pointer
col = editorcolors[15 - 3*gridlock]; col = searchlock ? editorcolors[13] : editorcolors[15 - 3*gridlock];
if (joinsector[0] >= 0) if (joinsector[0] >= 0)
col = editorcolors[11]; col = editorcolors[11];
@ -5961,8 +5967,17 @@ end_point_dragging:
if (keystatus[0x26]) // L (grid lock) if (keystatus[0x26]) // L (grid lock)
{ {
keystatus[0x26] = 0; keystatus[0x26] = 0;
gridlock = !gridlock;
printmessage16("Grid locking %s", gridlock?"on":"off"); if (eitherSHIFT)
{
searchlock = 1-searchlock;
silentmessage("Selection lock %s", searchlock ? "on" : "off");
}
else
{
gridlock = !gridlock;
silentmessage("Grid locking %s", gridlock ? "on" : "off");
}
} }
if (keystatus[0x24]) // J (join sectors) if (keystatus[0x24]) // J (join sectors)
@ -8446,7 +8461,7 @@ static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line, int8_t
if (numwalls == 0) if (numwalls == 0)
return -1; return -1;
if (mouseb & 1) if (mouseb & 1 || searchlock)
return line; return line;
if (!ignore_pointhighlight && (pointhighlight&0xc000) == 16384) if (!ignore_pointhighlight && (pointhighlight&0xc000) == 16384)
@ -8521,7 +8536,7 @@ int32_t getpointhighlight(int32_t xplc, int32_t yplc, int32_t point)
if (numwalls == 0) if (numwalls == 0)
return -1; return -1;
if (mouseb & 1) if (mouseb & 1 || searchlock)
return point; return point;
if (grid < 1) if (grid < 1)

View file

@ -17178,8 +17178,8 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t
{ {
// Red walls. Show them on equal-height walls ONLY with setting 2. // Red walls. Show them on equal-height walls ONLY with setting 2.
int32_t bb = (z2 < z1); int32_t bb = (z2 < z1);
int32_t dx = mulscale11(sintable[(k+1024 + 1024*bb)&2047],zoome) / 2560; int32_t dx = mulscale11(sintable[(k+1024 + 1024*bb)&2047],min(4096, zoome)) / 2560;
int32_t dy = mulscale11(sintable[(k+512 + 1024*bb)&2047],zoome) / 2560; int32_t dy = mulscale11(sintable[(k+512 + 1024*bb)&2047],min(4096, zoome)) / 2560;
dy = scalescreeny(dy); dy = scalescreeny(dy);
drawline16mid(dax,day, dax+dx,day+dy, editorcolors[col]); drawline16mid(dax,day, dax+dx,day+dy, editorcolors[col]);
@ -17188,8 +17188,8 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t
else if (showheightindicators == 2) else if (showheightindicators == 2)
{ {
// Show them on white walls ONLY with setting 2. // Show them on white walls ONLY with setting 2.
int32_t dx = mulscale11(sintable[(k+2048)&2047],zoome) / 2560; int32_t dx = mulscale11(sintable[(k+2048)&2047],min(4096, zoome)) / 2560;
int32_t dy = mulscale11(sintable[(k+1536)&2047],zoome) / 2560; int32_t dy = mulscale11(sintable[(k+1536)&2047],min(4096, zoome)) / 2560;
dy = scalescreeny(dy); dy = scalescreeny(dy);
drawline16mid(dax,day, dax+dx,day+dy, editorcolors[col]); drawline16mid(dax,day, dax+dx,day+dy, editorcolors[col]);
@ -17321,8 +17321,10 @@ static void drawscreen_drawsprite(int32_t j, int32_t posxe, int32_t posye, int32
if (m32_sideview) if (m32_sideview)
y1 += getscreenvdisp(sprite[j].z-posze,zoome); y1 += getscreenvdisp(sprite[j].z-posze,zoome);
if ((halfxdim16+x1 >= 0) && (halfxdim16+x1 < xdim) && int f = mulscale12(128, zoome);
(midydim16+y1 >= 0) && (midydim16+y1 < ydim16))
if ((halfxdim16+x1 >= -f) && (halfxdim16+x1 < xdim+f) &&
(midydim16+y1 >= -f) && (midydim16+y1 < ydim16+f))
{ {
if (zoome > 512 && sprite[j].clipdist > 32) if (zoome > 512 && sprite[j].clipdist > 32)
drawcircle16(halfxdim16+x1, midydim16+y1, mulscale14(sprite[j].clipdist<<2, zoome), 16384, col); drawcircle16(halfxdim16+x1, midydim16+y1, mulscale14(sprite[j].clipdist<<2, zoome), 16384, col);
@ -17596,9 +17598,11 @@ static int32_t printext_checkypos(int32_t ypos, int32_t *yminptr, int32_t *ymaxp
if (ypos < 0) if (ypos < 0)
{ {
/*
ymin = 0-ypos; ymin = 0-ypos;
if (ymin > 7) if (ymin > 7)
return 1; return 1;
*/
} }
else if (ypos+7 >= ydim) else if (ypos+7 >= ydim)
{ {
@ -17725,8 +17729,8 @@ int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, con
{ {
for (x=0; x<charxsiz; x++) for (x=0; x<charxsiz; x++)
{ {
if (stx+x >= xdim) if ((unsigned)(stx+x) >= xdim || ptr < (char *)frameplace)
break; continue;
if (letptr[y]&pow2char[7-(fontsize&1)-x]) if (letptr[y]&pow2char[7-(fontsize&1)-x])
ptr[x] = (uint8_t)col; ptr[x] = (uint8_t)col;
else if (backcol >= 0) else if (backcol >= 0)

View file

@ -670,8 +670,8 @@ const char *ExtGetSectorType(int32_t lotag)
{ {
switch (lotag) switch (lotag)
{ {
case 1: return "WATER (SE 7)"; case 1: return "WATER";
case 2: return "UNDERWATER (SE 7)"; case 2: return "UNDERWATER";
case 9: return "STAR TREK DOORS"; case 9: return "STAR TREK DOORS";
case 15: return "ELEVATOR TRANSPORT (SE 17)"; case 15: return "ELEVATOR TRANSPORT (SE 17)";
case 16: return "ELEVATOR PLATFORM DOWN"; case 16: return "ELEVATOR PLATFORM DOWN";
@ -689,7 +689,7 @@ const char *ExtGetSectorType(int32_t lotag)
case 29: return "TEETH DOOR (SE 22)"; case 29: return "TEETH DOOR (SE 22)";
case 30: return "ROTATE RISE BRIDGE"; case 30: return "ROTATE RISE BRIDGE";
case 31: return "2 WAY TRAIN (SE=30)"; case 31: return "2 WAY TRAIN (SE=30)";
case 32767: return "SECRET ROOM"; case 32767: return "SECRET AREA";
case -1: return "END OF LEVEL"; case -1: return "END OF LEVEL";
default: default:
if (lotag > 10000 && lotag < 32767) if (lotag > 10000 && lotag < 32767)
@ -779,17 +779,17 @@ const char *SectorEffectorTagText(int32_t lotag)
static const char *tags[] = static const char *tags[] =
{ {
"ROTATED SECTOR", // 0 "ROTATED SECTOR", // 0
"PIVOT SPRITE FOR SE 0", "ROTATION PIVOT",
"EARTHQUAKE", "EARTHQUAKE",
"RANDOM LIGHTS AFTER SHOT OUT", "RANDOM LIGHTS AFTER SHOT OUT",
"RANDOM LIGHTS", "RANDOM LIGHTS",
"(UNKNOWN)", // 5 "(UNKNOWN)", // 5
"SUBWAY", "SUBWAY",
"TRANSPORT", "TRANSPORT",
"UP OPEN DOOR LIGHTS", "RISING DOOR LIGHTS",
"DOWN OPEN DOOR LIGHTS", "LOWERING DOOR LIGHTS",
"DOOR AUTO CLOSE (H=DELAY)", // 10 "DOOR CLOSE DELAY", // 10
"ROTATE SECTOR DOOR", "SWING DOOR PIVOT (ST 23)",
"LIGHT SWITCH", "LIGHT SWITCH",
"EXPLOSIVE", "EXPLOSIVE",
"SUBWAY CAR", "SUBWAY CAR",
@ -801,34 +801,34 @@ const char *SectorEffectorTagText(int32_t lotag)
"BRIDGE (ST 27)", // 20 "BRIDGE (ST 27)", // 20
"DROP FLOOR (ST 28)", "DROP FLOOR (ST 28)",
"TEETH DOOR (ST 29)", "TEETH DOOR (ST 29)",
"1-WAY SE7 DESTINATION (H=SE 7)", "1-WAY TRANSPORT DESTINATION",
"CONVEYER BELT", "CONVEYOR BELT",
"ENGINE", // 25 "ENGINE", // 25
"(UNKNOWN)", "(UNKNOWN)",
"CAMERA FOR PLAYBACK", "DEMO CAMERA",
"LIGHTNING (H=TILE#4890)", "LIGHTNING (4890) CONTROLLER",
"FLOAT", "FLOAT",
"2 WAY TRAIN (ST=31)", // 30 "2 WAY TRAIN (ST 31)", // 30
"FLOOR RISE/FALL", "FLOOR Z",
"CEILING RISE/FALL", "CEILING Z",
"SPAWN JIB W/QUAKE", "EARTHQUAKE DEBRIS",
}; };
Bmemset(tempbuf,0,sizeof(tempbuf)); Bmemset(tempbuf,0,sizeof(tempbuf));
if (lotag>=0 && lotag<(int32_t)ARRAY_SIZE(tags)) if (lotag>=0 && lotag<(int32_t)ARRAY_SIZE(tags))
Bsprintf(tempbuf, "%d: %s", lotag, tags[lotag]); Bsprintf(tempbuf, "%s", tags[lotag]);
else else
switch (lotag) switch (lotag)
{ {
case 36: case 36:
Bsprintf(tempbuf,"%d: SHOOTER",lotag); Bsprintf(tempbuf,"SHOOTER");
break; break;
case 49: case 49:
Bsprintf(tempbuf,"%d: POINT LIGHT",lotag); Bsprintf(tempbuf,"POINT LIGHT");
break; break;
case 50: case 50:
Bsprintf(tempbuf,"%d: SPOTLIGHT",lotag); Bsprintf(tempbuf,"SPOTLIGHT");
break; break;
default: default:
Bsprintf(tempbuf,"%d: (UNKNOWN)",lotag); Bsprintf(tempbuf,"%d: (UNKNOWN)",lotag);
@ -866,7 +866,11 @@ const char *SectorEffectorText(int32_t spritenum)
if (!lo[5]) // tags are 5 chars or less if (!lo[5]) // tags are 5 chars or less
SpriteName(spritenum, tempbuf); SpriteName(spritenum, tempbuf);
else else
Bsprintf(tempbuf, "SE %s",lo); {
if (cursprite == spritenum)
Bsprintf(tempbuf, "SE %d %s", sprite[spritenum].lotag, lo);
else Bstrcpy(tempbuf, lo);
}
return (tempbuf); return (tempbuf);
} }
@ -10250,8 +10254,11 @@ void ExtPreCheckKeys(void) // just before drawrooms
ydim16 = ydim - STATUS2DSIZ2; // XXX? ydim16 = ydim - STATUS2DSIZ2; // XXX?
if (xp1 < 4 || xp1 > xdim-6 || yp1 < 4 || yp1 > ydim16-6) int f = mulscale12(128, zoom);
if (xp1 < -f || xp1 > xdim+f || yp1 < -f || yp1 > ydim16+f)
continue; continue;
rotatesprite(xp1<<16,yp1<<16,zoom<<5,daang,picnum, rotatesprite(xp1<<16,yp1<<16,zoom<<5,daang,picnum,
shade,sprite[i].pal,flags,0,0,xdim-1,ydim16-1); shade,sprite[i].pal,flags,0,0,xdim-1,ydim16-1);
} }
@ -10478,7 +10485,10 @@ static void Keys2d3d(void)
{ {
keystatus[KEYSC_F10]=0; keystatus[KEYSC_F10]=0;
if (!in3dmode()) if (xdimgame != xdim2d || ydimgame != ydim2d)
message("2d and 3d mode resolutions don't match!");
else if (!in3dmode())
{ {
if (eitherSHIFT) if (eitherSHIFT)
{ {
@ -10492,12 +10502,12 @@ static void Keys2d3d(void)
if (++m32_2d3dsize > 5) if (++m32_2d3dsize > 5)
m32_2d3dsize = 3; m32_2d3dsize = 3;
printmessage16("2d3d size %d", m32_2d3dsize); message("2d3d size %d", m32_2d3dsize);
} }
else else
{ {
m32_2d3dmode = !m32_2d3dmode; m32_2d3dmode = !m32_2d3dmode;
printmessage16("2d3d mode %s", m32_2d3dmode ? "enabled" : "disabled"); message("2d3d mode %s", m32_2d3dmode ? "enabled" : "disabled");
} }
} }
} }

View file

@ -2517,7 +2517,7 @@ badindex:
{ {
drawsmallabel(quotetext, drawsmallabel(quotetext,
editorcolors[backcol&255], // col editorcolors[backcol&255], // col
fontsize < 0 ? -1 : editorcolors[fontsize&255], // backcol fontsize < 0 ? -1 : editorcolors[fontsize&255], editorcolors[fontsize&255] - 3, // backcol
x, y, col); // x y z x, y, col); // x y z
} }
} }