From 2bebe0fa6aa3a178ba55f63f86a7e3957e3f2fb8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Oct 2020 20:09:19 +0100 Subject: [PATCH] - the WH intro movies are playing now. --- source/common/filesystem/resourcefile.cpp | 3 +- source/core/initfs.cpp | 2 +- source/core/menu/razemenu.cpp | 9 +++ source/core/searchpaths.cpp | 5 +- source/games/whaven/CMakeLists.txt | 2 + source/games/whaven/src/2d.cpp | 28 +++++++ source/games/whaven/src/fonts.cpp | 46 +++++++++++ source/games/whaven/src/main.cpp | 19 +++-- source/games/whaven/src/sound.cpp | 96 +++++++++++++++++++++++ source/games/whaven/src/wh.h | 5 ++ 10 files changed, 206 insertions(+), 9 deletions(-) create mode 100644 source/games/whaven/src/fonts.cpp create mode 100644 source/games/whaven/src/sound.cpp diff --git a/source/common/filesystem/resourcefile.cpp b/source/common/filesystem/resourcefile.cpp index d718d74ec..0ad8f58b3 100644 --- a/source/common/filesystem/resourcefile.cpp +++ b/source/common/filesystem/resourcefile.cpp @@ -241,10 +241,11 @@ FResourceFile *CheckPak(const char *filename, FileReader &file, bool quiet, Lump FResourceFile *CheckZip(const char *filename, FileReader &file, bool quiet, LumpFilterInfo* filter); FResourceFile *Check7Z(const char *filename, FileReader &file, bool quiet, LumpFilterInfo* filter); FResourceFile* CheckSSI(const char* filename, FileReader& file, bool quiet, LumpFilterInfo* filter); +FResourceFile* CheckWHRes(const char* filename, FileReader& file, bool quiet, LumpFilterInfo* filter); FResourceFile *CheckLump(const char *filename,FileReader &file, bool quiet, LumpFilterInfo* filter); FResourceFile *CheckDir(const char *filename, bool quiet, bool nosub, LumpFilterInfo* filter); -static CheckFunc funcs[] = { CheckWad, CheckZip, Check7Z, CheckPak, CheckGRP, CheckRFF, CheckSSI, CheckLump }; +static CheckFunc funcs[] = { CheckWad, CheckZip, Check7Z, CheckPak, CheckGRP, CheckRFF, CheckSSI, CheckWHRes, CheckLump }; FResourceFile *FResourceFile::DoOpenResourceFile(const char *filename, FileReader &file, bool quiet, bool containeronly, LumpFilterInfo* filter) { diff --git a/source/core/initfs.cpp b/source/core/initfs.cpp index f18fd50d3..bbb3a1b5b 100644 --- a/source/core/initfs.cpp +++ b/source/core/initfs.cpp @@ -52,7 +52,7 @@ #define PATH_MAX 260 #endif -static const char* validexts[] = { "*.grp", "*.zip", "*.pk3", "*.pk4", "*.7z", "*.pk7", "*.dat", "*.rff" }; +static const char* validexts[] = { "*.grp", "*.zip", "*.pk3", "*.pk4", "*.7z", "*.pk7", "*.dat", "*.rff", "*.ssi" }; //========================================================================== // diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index 7e306ff03..adb8bb13b 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -586,6 +586,15 @@ void SetDefaultMenuColors() gameinfo.mSliderColor = "Yellow"; cls = PClass::FindClass("ExhumedMenuDelegate"); } + else if (g_gameType & (GAMEFLAG_WH | GAMEFLAG_WH2)) + { + OptionSettings.mFontColorHeader = CR_DARKGREEN; + OptionSettings.mFontColorHighlight = CR_GRAY; + OptionSettings.mFontColorSelection = CR_GREEN; + OptionSettings.mFontColor = CR_FIRE; + gameinfo.mSliderColor = "Yellow"; + cls = PClass::FindClass(g_gameType & GAMEFLAG_WH2? "WH2MenuDelegate" : "WHMenuDelegate"); + } else { if (g_gameType & (GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI)) diff --git a/source/core/searchpaths.cpp b/source/core/searchpaths.cpp index 5f948a77c..d74f558c0 100644 --- a/source/core/searchpaths.cpp +++ b/source/core/searchpaths.cpp @@ -47,7 +47,7 @@ #include "filesystem.h" #include "findfile.h" -static const char* res_exts[] = { ".grp", ".zip", ".pk3", ".pk4", ".7z", ".pk7" }; +static const char* res_exts[] = { ".grp", ".zip", ".pk3", ".pk4", ".7z", ".pk7", "esnd" }; // 'esnd' is for 'JOESND' as used by the Capstone games int g_gameType; @@ -561,7 +561,8 @@ static TArray ParseGrpInfo(const char *fn, FileReader &fr, TMapValue->SetOffsetsNotForFont(); + SmallFont = new ::FFont("SmallFont", nullptr, "defsmallfont", 0, 0, 0, -1, 5, false, false, false, &fontdata); +} + + + END_WH_NS + \ No newline at end of file diff --git a/source/games/whaven/src/main.cpp b/source/games/whaven/src/main.cpp index f7a89bbf3..bce572785 100644 --- a/source/games/whaven/src/main.cpp +++ b/source/games/whaven/src/main.cpp @@ -203,6 +203,8 @@ static void readpalettetable(void) void GameInterface::app_init() { InitNames(); + engineInit(); + TileFiles.LoadArtSet("tiles%03d.art"); TileFiles.tileMakeWritable(ANILAVA); TileFiles.tileMakeWritable(HEALTHWATER); @@ -211,6 +213,8 @@ void GameInterface::app_init() //ConsoleInit(); g_visibility=1024; readpalettetable(); + TileFiles.SetBackup(); + InitFonts(); if(isWh2()) { tileDelete(FLOORMIRROR); @@ -229,6 +233,7 @@ void GameInterface::app_init() FadeInit(); setupmidi(); + sfxInit(); //sndInit(); //initpaletteshifts(); InitOriginalEpisodes(); @@ -236,12 +241,16 @@ void GameInterface::app_init() void GameInterface::Startup() { - /* - if (gCutsceneScreen.init("intro.smk")) - changeScreen(gCutsceneScreen.setSkipping(main).escSkipping(true)); + if (userConfig.CommandMap.IsNotEmpty()) + { + } else - changeScreen(gMenuScreen); - */ + { + IntroMovie([](bool) + { + gameaction = ga_mainmenu; + }); + } } ::GameInterface* CreateInterface() diff --git a/source/games/whaven/src/sound.cpp b/source/games/whaven/src/sound.cpp new file mode 100644 index 000000000..41d59dd2c --- /dev/null +++ b/source/games/whaven/src/sound.cpp @@ -0,0 +1,96 @@ +#include "ns.h" +#include "wh.h" +#include "raze_sound.h" + +BEGIN_WH_NS + +class WHSoundEngine : public SoundEngine +{ + // client specific parts of the sound engine go in this class. + void CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan *channel) override; + TArray ReadSound(int lumpnum) override; + +public: + WHSoundEngine() + { + S_Rolloff.RolloffType = ROLLOFF_Doom; + S_Rolloff.MinDistance = 170; // these are the numbers I got when uncrunching the original sound code. + S_Rolloff.MaxDistance = 850; + } + + void StopChannel(FSoundChan* chan) override + { + if (chan && chan->SysChannel != NULL && !(chan->ChanFlags & CHANF_EVICTED) && chan->SourceType == SOURCE_Actor) + { + chan->Source = NULL; + chan->SourceType = SOURCE_Unattached; + } + SoundEngine::StopChannel(chan); + } + + + +}; + +void sfxInit(void) +{ + soundEngine = new WHSoundEngine; +} + +void sfxTerm() +{ +} + +//========================================================================== +// +// +// +//========================================================================== + +TArray WHSoundEngine::ReadSound(int lumpnum) +{ + auto wlump = fileSystem.OpenFileReader(lumpnum); + return wlump.Read(); +} + +void WHSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan *) +{ +#if 0 + if (pos != nullptr && type != SOURCE_None) + { + FVector3 camera; + + if (gMe && gMe->pSprite) camera = GetSoundPos(&gMe->pSprite->pos); + else camera = { 0, 0, 0 }; // don't crash if there is no player. + + if (vel) vel->Zero(); + + if (type == SOURCE_Unattached) + { + pos->X = pt[0]; + pos->Y = pt[1]; + pos->Z = pt[2]; + } + else if (type == SOURCE_Actor) + { + auto actor = (spritetype*)source; + assert(actor != nullptr); + size_t index = actor - sprite; + // Engine expects velocity in units per second, not units per tic. + if (vel) *vel = { xvel[index] * (30 / 65536.f), zvel[index] * (-30 / 65536.f), yvel[index] * (-30 / 65536.f) }; + *pos = GetSoundPos(&actor->pos); + } + else if (type == SOURCE_Ambient) + { + *pos = camera; // just to be safe. Ambient sounds are in the world but unpositioned + } + if ((chanflags & CHANF_LISTENERZ)) + { + pos->Y = camera.Y; + } + } +#endif +} + + +END_WH_NS \ No newline at end of file diff --git a/source/games/whaven/src/wh.h b/source/games/whaven/src/wh.h index 43716babd..ac6d857c9 100644 --- a/source/games/whaven/src/wh.h +++ b/source/games/whaven/src/wh.h @@ -23,6 +23,7 @@ END_WH_NS #include "gstrings.h" #include "gamecontrol.h" #include "d_net.h" +#include "screenjob.h" BEGIN_WH_NS @@ -460,6 +461,10 @@ void showStatisticsScreen(); void showVictoryScreen(); void InitNames(); +void InitFonts(); +void sfxInit(void); + +void IntroMovie(const CompletionFunc& completion); #include "item.h"