mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 19:20:46 +00:00
- hooked up the secret hint system
This commit is contained in:
parent
35bc7f56fc
commit
8055d10362
5 changed files with 92 additions and 27 deletions
|
@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "pqueue.h"
|
#include "pqueue.h"
|
||||||
#include "triggers.h"
|
#include "triggers.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
|
#include "secrets.h"
|
||||||
|
|
||||||
BEGIN_BLD_NS
|
BEGIN_BLD_NS
|
||||||
|
|
||||||
|
@ -380,7 +381,7 @@ void evSend(int nIndex, int nType, int rxId, COMMAND_ID command, short causedBy)
|
||||||
else viewSetSystemMessage("Invalid Total-Secrets command by xobject #%d (object type %d)", nIndex, nType);
|
else viewSetSystemMessage("Invalid Total-Secrets command by xobject #%d (object type %d)", nIndex, nType);
|
||||||
break;
|
break;
|
||||||
case kChannelSecretFound:
|
case kChannelSecretFound:
|
||||||
Printf(PRINT_NONOTIFY, "Secret trigger %d\n", nIndex * 65536 + nType);
|
SECRET_Trigger(nIndex + 65536 * nType);
|
||||||
if (command >= kCmdNumberic) levelTriggerSecret(command - kCmdNumberic);
|
if (command >= kCmdNumberic) levelTriggerSecret(command - kCmdNumberic);
|
||||||
else viewSetSystemMessage("Invalid Trigger-Secret command by xobject #%d (object type %d)", nIndex, nType);
|
else viewSetSystemMessage("Invalid Trigger-Secret command by xobject #%d (object type %d)", nIndex, nType);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2,7 +2,45 @@
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
#include "v_text.h"
|
#include "v_text.h"
|
||||||
|
#include "tarray.h"
|
||||||
|
#include "c_cvars.h"
|
||||||
|
#include "v_font.h"
|
||||||
|
#include "v_draw.h"
|
||||||
|
|
||||||
|
// Unlike in GZDoom we have to maintain this list here, because we got different game frontents that all store this info differently.
|
||||||
|
// So the games will have to report the credited secrets so that this code can keep track of how to display them.
|
||||||
|
static TArray<int> discovered_secrets;
|
||||||
|
CVAR(Bool, secret_notify, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
|
||||||
|
FString mapfile, maptitle;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Print secret info (submitted by Karl Murks)
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void PrintSecretString(const char *string, bool thislevel)
|
||||||
|
{
|
||||||
|
const char *colstr = thislevel? TEXTCOLOR_YELLOW : TEXTCOLOR_CYAN;
|
||||||
|
if (string != NULL)
|
||||||
|
{
|
||||||
|
if (*string == '$')
|
||||||
|
{
|
||||||
|
if (string[1] == 'S' || string[1] == 's')
|
||||||
|
{
|
||||||
|
auto secnum = (unsigned)strtoull(string+2, (char**)&string, 10);
|
||||||
|
if (*string == ';') string++;
|
||||||
|
colstr = discovered_secrets.Find(secnum) == discovered_secrets.Size() ? TEXTCOLOR_RED : TEXTCOLOR_GREEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto brok = V_BreakLines(NewConsoleFont, screen->GetWidth()*95/100, string);
|
||||||
|
|
||||||
|
for (auto &line : brok)
|
||||||
|
{
|
||||||
|
Printf("%s%s\n", colstr, line.Text.GetChars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
//
|
//
|
||||||
|
@ -12,14 +50,14 @@
|
||||||
|
|
||||||
CCMD(secret)
|
CCMD(secret)
|
||||||
{
|
{
|
||||||
const char *mapname = argv.argc() < 2? primaryLevel->MapName.GetChars() : argv[1];
|
const char *mapname = argv.argc() < 2? mapfile.GetChars() : argv[1];
|
||||||
bool thislevel = !stricmp(mapname, primaryLevel->MapName);
|
bool thislevel = !stricmp(mapname, mapfile.GetChars());
|
||||||
bool foundsome = false;
|
bool foundsome = false;
|
||||||
|
|
||||||
int lumpno=Wads.CheckNumForName("SECRETS");
|
int lumpno=fileSystem.FindFile("secrets.txt");
|
||||||
if (lumpno < 0) return;
|
if (lumpno < 0) return;
|
||||||
|
|
||||||
auto lump = Wads.OpenLumpReader(lumpno);
|
auto lump = fileSystem.OpenFileReader(lumpno);
|
||||||
FString maphdr;
|
FString maphdr;
|
||||||
maphdr.Format("[%s]", mapname);
|
maphdr.Format("[%s]", mapname);
|
||||||
|
|
||||||
|
@ -37,9 +75,8 @@ CCMD(secret)
|
||||||
if (!foundsome)
|
if (!foundsome)
|
||||||
{
|
{
|
||||||
FString levelname;
|
FString levelname;
|
||||||
level_info_t *info = FindLevelInfo(mapname);
|
if (thislevel) levelname.Format("%s - %s", mapname, maptitle.GetChars());
|
||||||
const char *ln = !(info->flags & LEVEL_LOOKUPLEVELNAME)? info->LevelName.GetChars() : GStrings[info->LevelName.GetChars()];
|
else levelname = mapname;
|
||||||
levelname.Format("%s - %s", mapname, ln);
|
|
||||||
Printf(TEXTCOLOR_YELLOW "%s\n", levelname.GetChars());
|
Printf(TEXTCOLOR_YELLOW "%s\n", levelname.GetChars());
|
||||||
size_t llen = levelname.Len();
|
size_t llen = levelname.Len();
|
||||||
levelname = "";
|
levelname = "";
|
||||||
|
@ -69,16 +106,40 @@ CCMD(secret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECRET_Save(FileWriter &fil)
|
void SECRET_Save(FileWriter &fil)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SECRET_Load(FileReader &fil)
|
|
||||||
{
|
{
|
||||||
|
fil.Write("SECR", 4);
|
||||||
|
unsigned count = discovered_secrets.Size();
|
||||||
|
fil.Write(&count, 4);
|
||||||
|
fil.Write(discovered_secrets.Data(), 4 * count);
|
||||||
|
fil.Write("RCES", 4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECRET_Trigger(int num)
|
bool SECRET_Load(FileReader &fil)
|
||||||
{
|
{
|
||||||
|
char buf[4];
|
||||||
|
unsigned count;
|
||||||
|
fil.Read(buf, 4);
|
||||||
|
if (memcmp(buf, "SECR", 4)) return false;
|
||||||
|
fil.Read(&count, 4);
|
||||||
|
discovered_secrets.Resize(count);
|
||||||
|
fil.Read(discovered_secrets.Data(), count * 4);
|
||||||
|
fil.Read(buf, 4);
|
||||||
|
if (memcmp(buf, "RCES", 4)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SECRET_SetMapName(const char *filename, const char *_maptitle)
|
||||||
|
{
|
||||||
|
mapfile = filename;
|
||||||
|
maptitle = _maptitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SECRET_Trigger(int num)
|
||||||
|
{
|
||||||
|
if (secret_notify) Printf(PRINT_NONOTIFY, "Secret #%d found\n", num);
|
||||||
|
if (discovered_secrets.Find(num) == discovered_secrets.Size())
|
||||||
|
discovered_secrets.Push(num);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
|
|
||||||
SECRET_Save(FileWriter &fil);
|
void SECRET_Save(FileWriter &fil);
|
||||||
SECRET_Load(FileReader &fil);
|
bool SECRET_Load(FileReader &fil);
|
||||||
SECRET_Trigger(int num);
|
void SECRET_SetMapName(const char *filename, const char *maptitle);
|
||||||
|
void SECRET_Trigger(int num);
|
||||||
|
|
|
@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "duke3d.h"
|
#include "duke3d.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
#include "secrets.h"
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
@ -3123,7 +3124,7 @@ void P_CheckSectors(int playerNum)
|
||||||
case 32767:
|
case 32767:
|
||||||
pSector->lotag = 0;
|
pSector->lotag = 0;
|
||||||
P_DoQuote(QUOTE_FOUND_SECRET, pPlayer);
|
P_DoQuote(QUOTE_FOUND_SECRET, pPlayer);
|
||||||
Printf(PRINT_NONOTIFY, "Secret in sector %d\n", pPlayer->cursectnum);
|
SECRET_Trigger(pPlayer->cursectnum);
|
||||||
pPlayer->secret_rooms++;
|
pPlayer->secret_rooms++;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include "duke3d.h"
|
#include "duke3d.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "secrets.h"
|
||||||
|
|
||||||
BEGIN_RR_NS
|
BEGIN_RR_NS
|
||||||
|
|
||||||
|
@ -4284,7 +4285,7 @@ void P_CheckSectors(int playerNum)
|
||||||
if (RR && !RRRA)
|
if (RR && !RRRA)
|
||||||
g_canSeePlayer = 0;
|
g_canSeePlayer = 0;
|
||||||
P_DoQuote(QUOTE_FOUND_SECRET, pPlayer);
|
P_DoQuote(QUOTE_FOUND_SECRET, pPlayer);
|
||||||
Printf(PRINT_NONOTIFY, "Secret in sector %d\n", pPlayer->cursectnum);
|
SECRET_Trigger(pPlayer->cursectnum);
|
||||||
pPlayer->secret_rooms++;
|
pPlayer->secret_rooms++;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue