Skip to content

Commit

Permalink
Tag Finder from PrBoomX, and more
Browse files Browse the repository at this point in the history
Additionally, corrected mention of `stretch_to_fit` in readme, and some reformatting.
  • Loading branch information
MrAlaux committed Aug 30, 2023
1 parent c80ee82 commit 395f70e
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- **Horizontal Weapon Centering** setting
- **_Switch [Weapon] on Pickup_** setting
- **Key to equip last used weapon**
- **_Tag Finder_** from PrBoomX
- **Key to teleport to Automap pointer**
- **_Blink Missing Keys_** setting
- **Support for optional sounds** (Crispy Doom's and more)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A few settings are labeled as _**CFG-Only**_: they can only be toggled by editin

- **Support for higher resolutions:** 4X (800p) and 8X (1600p)
- **Selection of widescreen ratios** in the setup menu itself [i.b. Crispy Doom]
- Toggle to **stretch viewport to fit window** (CFG-Only: `stretch-to-fit`) [i.b. and partially p.f. Crispy Doom; i.b. ZDoom]
- Toggle to **stretch viewport to fit window** (CFG-Only: `stretch_to_fit`) [i.b. and partially p.f. Crispy Doom; i.b. ZDoom]
- **Gamma Correction slider ranging from 0.50 to 2.0 in steps of 0.05**
- Toggle for **Gamma Correction key cycling**, through either original or extended gamma levels (CFG-Only: `gammacycle`)
- **Tweaked _Stretch Short Skies_ algorithm**
Expand Down Expand Up @@ -92,6 +92,7 @@ A few settings are labeled as _**CFG-Only**_: they can only be toggled by editin

- **Automap color for unrevealed secret sectors**
- Key to _**Blink [Automap] Marks**_ (default: <kbd>B</kbd>)
- _**Tag Finder**_ [p.f. PrBoomX]
- Key to _**Teleport to Automap pointer**_

### Enemies
Expand Down
185 changes: 157 additions & 28 deletions src/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@
#include "s_sound.h"
#include "sounds.h"

// [Nugget] Tag Finder from PrBoomX /------------

static boolean findtag;

#define MAGIC_SECTOR_COLOR_MIN 168
#define MAGIC_SECTOR_COLOR_MAX 180
#define MAGIC_LINE_COLOR_MIN 112
#define MAGIC_LINE_COLOR_MAX 124
static int magic_sector_color_pos = MAGIC_SECTOR_COLOR_MIN;
static int magic_line_color_pos = MAGIC_LINE_COLOR_MIN;

static sector_t* magic_sector;
static short magic_tag = -1;

// [Nugget] Tag Finder from PrBoomX ------------/

//jff 1/7/98 default automap colors added
int mapcolor_back; // map background
int mapcolor_grid; // grid lines color
Expand Down Expand Up @@ -688,6 +704,11 @@ void AM_Stop (void)
automapactive = false;
ST_Responder(&st_notify);
stopped = true;

// [Nugget] Tag Finder from PrBoomX
findtag = false;
magic_sector = NULL;
magic_tag = -1;
}

//
Expand Down Expand Up @@ -897,33 +918,6 @@ boolean AM_Responder
displaymsg("Cleared spot %d", markpointnum);
}
}
// [Nugget] Blink marks
else if (M_InputActivated(input_map_blink) && markpointnum)
{
markblinktimer = 4*TICRATE;
plr->message = "Blinking marks...";
}
// [Nugget] Teleport to Automap pointer
else if (M_InputActivated(input_map_teleport) && !followplayer)
{
mobj_t *const mo = plr->mo;

P_MapStart();

P_TeleportMove(mo, (m_x+m_w/2)<<FRACTOMAPBITS, (m_y+m_h/2)<<FRACTOMAPBITS, false);
mo->z = mo->floorz;
plr->viewz = mo->z + plr->viewheight;

if (fancy_teleport) {
R_SetFOVFX(FOVFX_TELEPORT); // Teleporter zoom
S_StartSound(P_SpawnMobj(mo->x + 20 * finecosine[mo->angle>>ANGLETOFINESHIFT],
mo->y + 20 * finesine[mo->angle>>ANGLETOFINESHIFT],
mo->z, MT_TFOG),
sfx_telept);
}

P_MapEnd();
}
else
if (M_InputActivated(input_map_overlay))
{
Expand Down Expand Up @@ -952,6 +946,44 @@ boolean AM_Responder
else
displaymsg("%s", s_AMSTR_ROTATEOFF);
}

// [Nugget] /----------------------

// Blink marks
else if (M_InputActivated(input_map_blink) && markpointnum)
{
markblinktimer = 4*TICRATE;
plr->message = "Blinking marks...";
}
// Tag Finder from PrBoomX
else if (M_InputActivated(input_map_tagfinder))
{
findtag = !strictmode;
}
// Teleport to Automap pointer
else if (M_InputActivated(input_map_teleport) && !followplayer)
{
mobj_t *const mo = plr->mo;

P_MapStart();

P_TeleportMove(mo, (m_x+m_w/2)<<FRACTOMAPBITS, (m_y+m_h/2)<<FRACTOMAPBITS, false);
mo->z = mo->floorz;
plr->viewz = mo->z + plr->viewheight;

if (fancy_teleport) {
R_SetFOVFX(FOVFX_TELEPORT); // Teleporter zoom
S_StartSound(P_SpawnMobj(mo->x + 20 * finecosine[mo->angle>>ANGLETOFINESHIFT],
mo->y + 20 * finesine[mo->angle>>ANGLETOFINESHIFT],
mo->z, MT_TFOG),
sfx_telept);
}

P_MapEnd();
}

// [Nugget] ----------------------/

else
{
rc = false;
Expand Down Expand Up @@ -991,6 +1023,11 @@ boolean AM_Responder
{
buttons_state[ZOOM_IN] = 0;
}
// [Nugget] Tag Finder from PrBoomX
else if (M_InputDeactivated(input_map_tagfinder))
{
findtag = false;
}
}

m_paninc.x = 0;
Expand Down Expand Up @@ -1098,6 +1135,63 @@ void AM_Ticker (void)
// [Nugget] Blink marks
if (markblinktimer) { markblinktimer--; }

// [Nugget] Tag Finder from PrBoomX /----------

if (findtag)
{
const fixed_t tmapx = (m_x + m_w/2);
const fixed_t tmapy = (m_y + m_h/2);
const subsector_t *const subsec = R_PointInSubsector(tmapx<<FRACTOMAPBITS,
tmapy<<FRACTOMAPBITS);

if (subsec && subsec->sector)
{
// if we are close to a tagged line in the sector, choose it instead
float min_distance = 24 << MAPBITS;
short int min_tag = 0;

magic_sector = (subsec->sector->tag > 0) ? subsec->sector : NULL;
magic_tag = -1;

for (int i = 0; i < subsec->sector->linecount; i++)
{
line_t* l = subsec->sector->lines[i];
if (l && (l->tag > 0)) {
if (l->v1 && l->v2) {
const float
x1 = (l->v1->x >> FRACTOMAPBITS),
x2 = (l->v2->x >> FRACTOMAPBITS),
y1 = (l->v1->y >> FRACTOMAPBITS),
y2 = (l->v2->y >> FRACTOMAPBITS),
dist = fabs((y2 - y1) * tmapx - (x2 - x1) * tmapy + x2*y1 - y2*x1)
/ sqrtf(powf(y2 - y1, 2) + powf(x2 - x1, 2));

if (dist < min_distance) {
min_distance = dist;
min_tag = l->tag;
}
}
}
}
// only pick the line if the crosshair is "close" to it
if (min_tag > 0) {
magic_tag = min_tag;
magic_sector = NULL;
}
}
}

if (magic_sector || magic_tag > 0)
{
if (++magic_sector_color_pos >= MAGIC_SECTOR_COLOR_MAX)
{ magic_sector_color_pos = MAGIC_SECTOR_COLOR_MIN; }

if (++magic_line_color_pos >= MAGIC_LINE_COLOR_MAX)
{ magic_line_color_pos = MAGIC_LINE_COLOR_MIN; }
}

// [Nugget] Tag Finder from PrBoomX ----------/

// Change the zoom if necessary.
if (ftom_zoommul != FRACUNIT)
{
Expand Down Expand Up @@ -1650,6 +1744,10 @@ static int AM_DoorColor(int type)
// jff 4/3/98 changed mapcolor_xxxx=0 as control to disable feature
// jff 4/3/98 changed mapcolor_xxxx=-1 to disable drawing line completely
//

// [Nugget] Tag Finder from PrBoomX: Prototype this function
static void AM_drawLineCharacter();

static void AM_drawWalls(void)
{
int i;
Expand All @@ -1672,7 +1770,8 @@ static void AM_drawWalls(void)
// if line has been seen or IDDT has been used
if (ddt_cheating || (lines[i].flags & ML_MAPPED))
{
if ((lines[i].flags & ML_DONTDRAW) && !ddt_cheating)
if ((lines[i].flags & ML_DONTDRAW) && !ddt_cheating
&& lines[i].tag != magic_tag) // [Nugget] Tag Finder from PrBoomX
continue;
if (!lines[i].backsector)
{
Expand Down Expand Up @@ -1847,6 +1946,36 @@ static void AM_drawWalls(void)
AM_drawMline(&l, mapcolor_unsn);
}
}

// [Nugget] Tag Finder from PrBoomX: Highlight sectors and lines
if (magic_sector || magic_tag > 0)
{
if ( (lines[i].frontsector && ((magic_sector && lines[i].frontsector->tag == magic_sector->tag)
|| ((magic_tag > 0) && lines[i].frontsector->tag == magic_tag)))
|| (lines[i].backsector && ((magic_sector && lines[i].backsector->tag == magic_sector->tag)
|| ((magic_tag > 0) && lines[i].backsector->tag == magic_tag))))
{
AM_drawMline(&l, magic_sector_color_pos);

if (magic_sector_color_pos <= MAGIC_SECTOR_COLOR_MIN+1)
{
AM_drawLineCharacter(cross_mark, NUMCROSSMARKLINES,
128<<MAPBITS, 0, 229, l.a.x, l.a.y);
}
}

if ( (lines[i].tag > 0)
&& (lines[i].tag == magic_tag || (magic_sector && (lines[i].tag == magic_sector->tag))))
{
AM_drawMline(&l, magic_line_color_pos);

if (magic_line_color_pos <= MAGIC_LINE_COLOR_MIN+1)
{
AM_drawLineCharacter(cross_mark, NUMCROSSMARKLINES,
128<<MAPBITS, 0, 251, l.a.x, l.a.y);
}
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/m_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ enum
input_map_mark,
input_map_clear,
input_map_blink, // [Nugget] Blink marks
input_map_tagfinder, // [Nugget] Tag Finder from PrBoomX
input_map_teleport, // [Nugget] Teleport to Automap pointer
input_map_gobig,
input_map_grid,
Expand Down
6 changes: 5 additions & 1 deletion src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3123,8 +3123,10 @@ enum {
keys10_stub3,
keys10_chasecam,
keys10_stub4,
keys10_tpointer,
keys10_tagfind,
keys10_stub5,
keys10_tpointer,
keys10_stub6,
keys10_fancytp,
};

Expand All @@ -3141,6 +3143,8 @@ setup_menu_t keys_settings10[] =
{"", S_SKIP, m_null, KB_X, M_Y + keys10_stub3 * M_SPC},
{"CYCLE CHASECAM", S_INPUT|S_STRICT, m_scrn, KB_X, M_Y + keys10_chasecam * M_SPC, {0}, input_chasecam},
{"", S_SKIP, m_null, KB_X, M_Y + keys10_stub4 * M_SPC},
{"TAG FINDER", S_INPUT|S_STRICT, m_scrn, KB_X, M_Y + keys10_tagfind * M_SPC, {0}, input_map_tagfinder},
{"", S_SKIP, m_null, KB_X, M_Y + keys10_stub5 * M_SPC},
{"TELEPORT TO\n"
"AUTOMAP POINTER", S_INPUT|S_STRICT|S_CRITICAL, m_scrn, KB_X, M_Y + keys10_tpointer * M_SPC, {0}, input_map_teleport},
{"FANCY TELEPORT", S_YESNO|S_STRICT|S_CRITICAL, m_null, KB_X, M_Y + keys10_fancytp * M_SPC, {"fancy_teleport"}},
Expand Down
8 changes: 8 additions & 0 deletions src/m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2501,6 +2501,14 @@ default_t defaults[] = {
input_map_blink, { {input_type_key, 'b'} }
},

{
"input_map_tagfinder",
NULL, NULL,
{0}, {UL,UL}, input, ss_keys, wad_no,
"key to find associated sectors and lines",
input_map_tagfinder, { {0, 0} }
},

{
"input_map_teleport",
NULL, NULL,
Expand Down

0 comments on commit 395f70e

Please sign in to comment.