Skip to content

Commit 883c78b

Browse files
Door keys (#530)
* Fix for remaster darkpilo.cfg which is not located in the game folder. * Add for linux compatibility * Update Linux pathing. * fix for nix paths * change the path path based on testing on proton. * Add map colors POC --------- Co-authored-by: Karjala22 <78927981+Karjala22@users.noreply.github.com>
1 parent 3d68d2e commit 883c78b

File tree

6 files changed

+62
-2
lines changed

6 files changed

+62
-2
lines changed

TheForceEngine/TFE_DarkForces/automap.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
#include <TFE_Jedi/Level/rwall.h>
99
#include <TFE_Jedi/Memory/list.h>
1010
#include <TFE_Jedi/InfSystem/infSystem.h>
11+
#include <TFE_Jedi/InfSystem/infTypesInternal.h>
1112
#include <TFE_Jedi/Renderer/jediRenderer.h>
1213
#include <TFE_Jedi/Renderer/screenDraw.h>
1314
#include <TFE_Jedi/Serialization/serialization.h>
15+
#include <TFE_Settings/settings.h>
1416

1517
using namespace TFE_Jedi;
1618

@@ -35,6 +37,14 @@ namespace TFE_DarkForces
3537
MOBJCOLOR_SCENERY = 21,
3638
};
3739

40+
enum MapKeyColor
41+
{
42+
KEY_COLOR_RED = 6,
43+
KEY_COLOR_BLUE = 17,
44+
// Not sure which yellow to use which overlaps with elevators (19).
45+
KEY_COLOR_YELLOW = 20
46+
};
47+
3848
enum MapConstants
3949
{
4050
MOBJSPRITE_DRAW_LEN = FIXED(2)
@@ -489,9 +499,31 @@ namespace TFE_DarkForces
489499
automap_drawLine(x0, z0, x1, z1, color);
490500
}
491501

502+
// Note it assumes the wall adjoins a door sector
503+
u8 getDoorKeyColor(RWall* wall)
504+
{
505+
KeyItem key = (KeyItem)sector_getKey(wall->sector);
506+
if (key == KEY_NONE)
507+
{
508+
key = (KeyItem)sector_getKey(wall->nextSector);
509+
}
510+
switch (key)
511+
{
512+
case KEY_YELLOW:
513+
return KEY_COLOR_YELLOW;
514+
case KEY_RED:
515+
return KEY_COLOR_RED;
516+
case KEY_BLUE:
517+
return KEY_COLOR_BLUE;
518+
default:
519+
return WCOLOR_DOOR;
520+
}
521+
}
522+
492523
u8 automap_getWallColor(RWall* wall)
493524
{
494525
u8 color;
526+
bool showKeyDoors = TFE_Settings::getGameSettings()->df_showKeyColors;
495527
if (wall->flags1 & WF1_HIDE_ON_MAP)
496528
{
497529
color = WCOLOR_INVISIBLE;
@@ -508,7 +540,11 @@ namespace TFE_DarkForces
508540
{
509541
color = WCOLOR_NORMAL;
510542
}
511-
else if (sector_isDoor(wall->sector) || sector_isDoor(wall->nextSector))
543+
else if (showKeyDoors && (sector_getKey(wall->nextSector) || sector_getKey(wall->sector)))
544+
{
545+
color = getDoorKeyColor(wall);
546+
}
547+
else if (sector_isDoor(wall->sector) || sector_isDoor(wall->nextSector) )
512548
{
513549
color = WCOLOR_DOOR;
514550
}

TheForceEngine/TFE_FrontEndUI/frontEndUi.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,12 @@ namespace TFE_FrontEndUI
12301230
gameSettings->df_autoEndMission = autoEndMission;
12311231
}
12321232

1233+
bool showKeyColors = gameSettings->df_showKeyColors;
1234+
if (ImGui::Checkbox("Show the key color of the door on the map", &showKeyColors))
1235+
{
1236+
gameSettings->df_showKeyColors = showKeyColors;
1237+
}
1238+
12331239
ImGui::Separator();
12341240

12351241
ImGui::PushFont(s_versionFont);

TheForceEngine/TFE_Jedi/InfSystem/infSystem.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3835,4 +3835,15 @@ namespace TFE_Jedi
38353835
}
38363836
return JFALSE;
38373837
}
3838+
3839+
u8 sector_getKey(RSector* sector)
3840+
{
3841+
InfLink* link = (InfLink*)allocator_getHead(sector->infLink);
3842+
if (link && link->type == LTYPE_SECTOR)
3843+
{
3844+
InfElevator* elev = link->elev;
3845+
return elev->key;
3846+
}
3847+
return KEY_NONE;
3848+
}
38383849
}

TheForceEngine/TFE_Jedi/InfSystem/infSystem.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ namespace TFE_Jedi
8787
void inf_sendLinkMessages(Allocator* infLink, SecObject* entity, u32 evt, MessageType msgType);
8888

8989
JBool sector_isDoor(RSector* sector);
90+
u8 sector_getKey(RSector* sector);
9091
}

TheForceEngine/TFE_Settings/settings.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ namespace TFE_Settings
545545
writeKeyValue_Bool(settings, "df_enableRecordingAll", s_gameSettings.df_enableRecordingAll);
546546
writeKeyValue_Bool(settings, "df_demologging", s_gameSettings.df_demologging);
547547
writeKeyValue_Bool(settings, "df_autoNextMission", s_gameSettings.df_autoEndMission);
548+
writeKeyValue_Bool(settings, "df_showKeyColors", s_gameSettings.df_showKeyColors);
548549
}
549550

550551
void writePerGameSettings(FileStream& settings)
@@ -1206,6 +1207,10 @@ namespace TFE_Settings
12061207
{
12071208
s_gameSettings.df_autoEndMission = parseBool(value);
12081209
}
1210+
else if (strcasecmp("df_showKeyColors", key) == 0)
1211+
{
1212+
s_gameSettings.df_showKeyColors = parseBool(value);
1213+
}
12091214
}
12101215

12111216
void parseOutlawsSettings(const char* key, const char* value)

TheForceEngine/TFE_Settings/settings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ struct TFE_Settings_Game
227227
bool df_enableReplay = false; // Enable replay of gameplay.
228228
bool df_showReplayCounter = false; // Show the replay counter on the HUD.
229229
bool df_demologging = false; // Log the record/playback logging
230-
bool df_autoEndMission = false; // Automatically skip to the next mission
230+
bool df_autoEndMission = false; // Automatically skip to the next mission
231+
bool df_showKeyColors = false; // Shows the door key color on the minimap
231232
s32 df_recordFrameRate = 4; // Recording Framerate value
232233
s32 df_playbackFrameRate = 2; // Playback Framerate value
233234
PitchLimit df_pitchLimit = PITCH_VANILLA_PLUS;

0 commit comments

Comments
 (0)