Skip to content

Commit 551c56b

Browse files
committed
Add Color Mapping POC.
1 parent f7a999c commit 551c56b

File tree

15 files changed

+574
-40
lines changed

15 files changed

+574
-40
lines changed

TheForceEngine/TFE_DarkForces/GameUI/agentMenu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ namespace TFE_DarkForces
2424
void agentMenu_createNewAgent();
2525
void agentMenu_setAgentName(const char* name);
2626
void agentMenu_resetState();
27+
void setPalette();
2728
}

TheForceEngine/TFE_DarkForces/automap.cpp

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,24 @@
22
#include "player.h"
33
#include "hud.h"
44
#include <TFE_DarkForces/sound.h>
5+
#include <TFE_FrontEndUI/frontEndUi.h>
56
#include <TFE_Jedi/Level/level.h>
67
#include <TFE_Jedi/Level/levelData.h>
78
#include <TFE_Jedi/Level/rsector.h>
89
#include <TFE_Jedi/Level/rwall.h>
910
#include <TFE_Jedi/Memory/list.h>
1011
#include <TFE_Jedi/InfSystem/infSystem.h>
12+
#include <TFE_Jedi/InfSystem/infTypesInternal.h>
1113
#include <TFE_Jedi/Renderer/jediRenderer.h>
1214
#include <TFE_Jedi/Renderer/screenDraw.h>
15+
#include <TFE_Jedi/Renderer/RClassic_GPU/screenDrawGPU.h>
1316
#include <TFE_Jedi/Serialization/serialization.h>
17+
#include <TFE_Settings/settings.h>
1418

1519
using namespace TFE_Jedi;
1620

1721
namespace TFE_DarkForces
1822
{
19-
enum MapWallColor
20-
{
21-
WCOLOR_INVISIBLE = 0,
22-
WCOLOR_NORMAL = 10,
23-
WCOLOR_LEDGE = 12,
24-
WCOLOR_GRAYED_OUT = 13,
25-
WCOLOR_DOOR = 19,
26-
};
27-
28-
enum MapObjectColor
29-
{
30-
MOBJCOLOR_DEFAULT = 19,
31-
MOBJCOLOR_PROJ = 6,
32-
MOBJCOLOR_CORPSE = 48,
33-
MOBJCOLOR_LANDMINE = 1,
34-
MOBJCOLOR_PICKUP = 152,
35-
MOBJCOLOR_SCENERY = 21,
36-
};
3723

3824
enum MapConstants
3925
{
@@ -112,7 +98,7 @@ namespace TFE_DarkForces
11298
SERIALIZE(SaveVersionInit, s_mapZ0, 0);
11399
SERIALIZE(SaveVersionInit, s_mapZ1, 0);
114100
SERIALIZE(SaveVersionInit, s_mapLayer, 0);
115-
}
101+
}
116102

117103
// _computeScreenBounds() and computeScaledScreenBounds() in the original source:
118104
// computeScaledScreenBounds() calls _computeScreenBounds() - so merged here.
@@ -489,32 +475,86 @@ namespace TFE_DarkForces
489475
automap_drawLine(x0, z0, x1, z1, color);
490476
}
491477

478+
// Note it assumes the wall adjoins a door sector
479+
u8 getDoorKeyColor(RWall* wall)
480+
{
481+
KeyItem key = (KeyItem)sector_getKey(wall->sector);
482+
if (key == KEY_NONE)
483+
{
484+
key = (KeyItem)sector_getKey(wall->nextSector);
485+
}
486+
switch (key)
487+
{
488+
case KEY_YELLOW:
489+
return TFE_Settings::getMapColorByName("Yellow Key Wall")->colorMapIndex;
490+
case KEY_RED:
491+
return TFE_Settings::getMapColorByName("Red Key Wall")->colorMapIndex;
492+
case KEY_BLUE:
493+
return TFE_Settings::getMapColorByName("Blue Key Wall")->colorMapIndex;
494+
default:
495+
return TFE_Settings::getMapColorByName("Door Wall")->colorMapIndex;
496+
}
497+
}
498+
492499
u8 automap_getWallColor(RWall* wall)
493500
{
494501
u8 color;
502+
// Default thickness - GPU only
503+
setLineThickness(1.5f);
504+
495505
if (wall->flags1 & WF1_HIDE_ON_MAP)
496506
{
497-
color = WCOLOR_INVISIBLE;
507+
color = TFE_Settings::getMapColorByName("Invisible Wall")->colorMapIndex;
498508
}
499509
else if (wall->flags1 & WF1_SHOW_AS_LEDGE_ON_MAP)
500510
{
501-
color = WCOLOR_LEDGE;
511+
color = TFE_Settings::getMapColorByName("Ledge Wall")->colorMapIndex;
502512
}
503513
else if (wall->flags1 & WF1_SHOW_AS_DOOR_ON_MAP)
504514
{
505-
color = WCOLOR_DOOR;
515+
color = TFE_Settings::getMapColorByName("Door Wall")->colorMapIndex;
506516
}
507-
else if ((wall->flags1 & WF1_SHOW_NORMAL_ON_MAP) || !wall->nextSector)
517+
else if (wall->flags1 & WF1_SHOW_NORMAL_ON_MAP)
508518
{
509-
color = WCOLOR_NORMAL;
519+
color = TFE_Settings::getMapColorByName("Normal Wall")->colorMapIndex;
520+
}
521+
else if (TFE_Settings::getGameSettings()->df_showKeyColors && (sector_getKey(wall->sector) || (wall->nextSector && sector_getKey(wall->nextSector))))
522+
{
523+
setLineThickness(2.0f);
524+
color = getDoorKeyColor(wall);
525+
}
526+
else if (TFE_Settings::getGameSettings()->df_showMapSecrets && isSecretSector(wall->sector) || wall->nextSector && isSecretSector(wall->nextSector))
527+
{
528+
529+
// If Secret is discovered color it as such. Do not show nextsector secrets if they are not on your current layer.
530+
if (wall->sector->secretDiscovered || (wall->nextSector && wall->nextSector->secretDiscovered && wall->nextSector->layer == s_mapLayer))
531+
{
532+
533+
color = TFE_Settings::getMapColorByName("Secret Wall")->colorMapIndex;
534+
}
535+
// If you have map reveal show the secret as not found. Do not show adjoined walls that don't match the current layer.
536+
else if (s_mapShowSectorMode != 0 && isSecretSector(wall->sector) && wall->sector->layer == s_mapLayer
537+
&& !(wall->nextSector && wall->nextSector->layer != s_mapLayer))
538+
{
539+
color = TFE_Settings::getMapColorByName("Secret Not Found Wall")->colorMapIndex;
540+
}
541+
// Show it as a normal sector if no cheats and you didn't discover it.
542+
else
543+
{
544+
color = TFE_Settings::getMapColorByName("Normal Wall")->colorMapIndex;
545+
}
546+
}
547+
else if (!wall->nextSector)
548+
{
549+
color = TFE_Settings::getMapColorByName("Normal Wall")->colorMapIndex;
510550
}
511551
else if (sector_isDoor(wall->sector) || sector_isDoor(wall->nextSector))
512552
{
513-
color = WCOLOR_DOOR;
553+
color = TFE_Settings::getMapColorByName("Door Wall")->colorMapIndex;
514554
}
515555
else if (s_mapShowSectorMode == 2)
516556
{
517-
color = WCOLOR_GRAYED_OUT;
557+
color = TFE_Settings::getMapColorByName("Grayed Out Wall")->colorMapIndex;
518558
}
519559
else
520560
{
@@ -525,11 +565,11 @@ namespace TFE_DarkForces
525565
fixed16_16 floorDelta = TFE_Jedi::abs(curFloorHeight - nextFloorHeight);
526566
if (floorDelta >= 0x4000) // 0.25 units
527567
{
528-
color = WCOLOR_LEDGE;
568+
color = TFE_Settings::getMapColorByName("Ledge Wall")->colorMapIndex;
529569
}
530570
else
531571
{
532-
color = WCOLOR_INVISIBLE;
572+
color = TFE_Settings::getMapColorByName("Invisible Wall")->colorMapIndex;
533573
}
534574
}
535575

@@ -552,7 +592,7 @@ namespace TFE_DarkForces
552592
}
553593

554594
u8 color = automap_getWallColor(wall);
555-
if (color != WCOLOR_INVISIBLE)
595+
if (color != TFE_Settings::getMapColorByName("Invisible Wall")->colorMapIndex)
556596
{
557597
automap_drawWall(wall, color);
558598
}
@@ -579,28 +619,34 @@ namespace TFE_DarkForces
579619

580620
void automap_drawObject(SecObject* obj)
581621
{
582-
u8 color = MOBJCOLOR_DEFAULT;
622+
623+
if (!TFE_Settings::getGameSettings()->df_showMapObjects)
624+
{
625+
return;
626+
}
627+
628+
u8 color = TFE_Settings::getMapColorByName("Default Object")->colorMapIndex;
583629
if (obj->flags & OBJ_FLAG_NEEDS_TRANSFORM)
584630
{
585631
if (obj->entityFlags & ETFLAG_PROJECTILE)
586632
{
587-
color = MOBJCOLOR_PROJ;
633+
color = TFE_Settings::getMapColorByName("Projectile Object")->colorMapIndex;
588634
}
589635
else if (obj->entityFlags & ETFLAG_CORPSE)
590636
{
591-
color = MOBJCOLOR_CORPSE;
637+
color = TFE_Settings::getMapColorByName("Corpse Object")->colorMapIndex;
592638
}
593639
else if (obj->entityFlags & ETFLAG_LANDMINE)
594640
{
595-
color = MOBJCOLOR_LANDMINE;
641+
color = TFE_Settings::getMapColorByName("Landmine Object")->colorMapIndex;
596642
}
597643
else if (obj->entityFlags & ETFLAG_PICKUP)
598644
{
599-
color = MOBJCOLOR_PICKUP;
645+
color = TFE_Settings::getMapColorByName("Pickup Object")->colorMapIndex;
600646
}
601647
else if (obj->entityFlags & ETFLAG_SCENERY)
602648
{
603-
color = MOBJCOLOR_SCENERY;
649+
color = TFE_Settings::getMapColorByName("Scenery Object")->colorMapIndex;
604650
}
605651

606652
ObjectType type = obj->type;

TheForceEngine/TFE_DarkForces/automap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <TFE_System/types.h>
77
#include <TFE_Jedi/Math/core_math.h>
88
#include <TFE_FileSystem/stream.h>
9+
#include <map>
910

1011
namespace TFE_DarkForces
1112
{

TheForceEngine/TFE_DarkForces/player.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,13 +2324,15 @@ namespace TFE_DarkForces
23242324
}
23252325
}
23262326

2327-
if (newSector->flags1 & SEC_FLAGS1_SECRET)
2327+
if (isSecretSector(newSector) && !newSector->secretDiscovered)
23282328
{
23292329
// If enabled, show the secret found message.
23302330
tfe_showSecretFoundMsg();
2331+
newSector->secretDiscovered = true;
23312332

23322333
// Remove the flag so the secret isn't counted twice.
2333-
newSector->flags1 &= ~SEC_FLAGS1_SECRET;
2334+
// No Longer needed ?
2335+
// newSector->flags1 &= ~SEC_FLAGS1_SECRET;
23342336
s_secretsFound++;
23352337
level_updateSecretPercent();
23362338
}

0 commit comments

Comments
 (0)