Initial Console integration

This commit is contained in:
Phillip Stephens 2018-01-15 08:00:20 -08:00
parent 7c699172cc
commit 030e80d843
14 changed files with 107 additions and 33 deletions

View File

@ -3,10 +3,16 @@
#include "../DNACommon.hpp"
namespace hecl
{
class CVarManager;
}
namespace DataSpec
{
struct ITweak : BigYAML
{
virtual void initCVars(hecl::CVarManager*) {}
};
}

View File

@ -1,11 +1,11 @@
#ifndef __DNACOMMON_ITWEAKGUICOLORS_HPP__
#define __DNACOMMON_ITWEAKGUICOLORS_HPP__
#include "../DNACommon.hpp"
#include "ITweak.hpp"
namespace DataSpec
{
struct ITweakGuiColors : BigYAML
struct ITweakGuiColors : ITweak
{
struct VisorEnergyInitColors
{

View File

@ -60,7 +60,8 @@ set(DNAMP1_SOURCES
DeafBabe.cpp
Tweaks/CTweakPlayer.cpp
Tweaks/CTweakTargeting.cpp
Tweaks/CTweakBall.cpp)
Tweaks/CTweakBall.cpp
Tweaks/CTweakGame.cpp)
dataspec_add_list(DNAMP1 DNAMP1_SOURCES)
list(APPEND DNAMP1_SOURCES ${liblist})

View File

@ -0,0 +1,11 @@
#include "CTweakGame.hpp"
#include "hecl/CVarManager.hpp"
namespace DataSpec::DNAMP1
{
void CTweakGame::initCVars(hecl::CVarManager* mgr)
{
mgr->findOrMakeCVar("tweaks.game.hardmodeDamageMult", "", x60_hardmodeDamageMult, hecl::CVar::EFlags::Game | hecl::CVar::Archive | hecl::CVar::Cheat);
mgr->findOrMakeCVar("tweaks.game.hardmodeWeaponMult", "", x64_hardmodeWeaponMult, hecl::CVar::EFlags::Game | hecl::CVar::Archive | hecl::CVar::Cheat);
}
}

View File

@ -55,6 +55,8 @@ struct CTweakGame final : ITweakGame
this->read(in);
x2b_splashScreensDisabled = false;
}
void initCVars(hecl::CVarManager* mgr);
};
}

View File

@ -29,7 +29,7 @@ namespace urde
void ViewManager::InitMP1(MP1::CMain& main)
{
main.Init(m_fileStoreManager, m_mainWindow.get(), m_voiceEngine.get(), *m_amuseAllocWrapper);
main.Init(m_fileStoreManager, &m_cvarManager, m_mainWindow.get(), m_voiceEngine.get(), *m_amuseAllocWrapper);
if (!m_noShaderWarmup)
main.WarmupShaders();

View File

@ -13,8 +13,6 @@ enum class EArchMsgTarget
{
IOWinManager = 0,
Game = 1,
/* URDE targets, we start at 255 */
ArchitectureSupport = 255,
};
enum class EArchMsgType
@ -30,8 +28,6 @@ enum class EArchMsgType
QuitGameplay = 8,
FrameBegin = 10,
FrameEnd = 11,
/* URDE messages, we start at 255 */
ApplicationExit = 255,
};
struct IArchMsgParm
@ -176,9 +172,9 @@ public:
std::make_shared<CArchMsgParmInt32>(a));
}
/* URDE Messages */
static CArchitectureMessage CreateApplicationExit(EArchMsgTarget target)
static CArchitectureMessage CreateRemoveAllIOWins(EArchMsgTarget target)
{
return CArchitectureMessage(target, EArchMsgType::ApplicationExit,
return CArchitectureMessage(target, EArchMsgType::RemoveAllIOWins,
std::make_shared<CArchMsgParmNull>());
}
};

View File

@ -7,6 +7,11 @@
#include <amuse/amuse.hpp>
#include "RetroTypes.hpp"
namespace hecl
{
class CVarManager;
}
namespace urde
{
class CStopWatch;
@ -34,6 +39,7 @@ class IMain
public:
virtual ~IMain() = default;
virtual void Init(const hecl::Runtime::FileStoreManager& storeMgr,
hecl::CVarManager* cvarMgr,
boo::IWindow* window,
boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend)=0;

View File

@ -36,7 +36,7 @@ static const SObjectTag& IDFromFactory(CResFactory& factory, const char* name)
return *tag;
}
void CTweaks::RegisterTweaks()
void CTweaks::RegisterTweaks(hecl::CVarManager* cvarMgr)
{
std::experimental::optional<CMemoryInStream> strm;
const SObjectTag* tag;
@ -45,11 +45,13 @@ void CTweaks::RegisterTweaks()
tag = g_ResFactory->GetResourceIdByName("Particle");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakParticle = new DataSpec::DNAMP1::CTweakParticle(*strm);
g_tweakParticle->initCVars(cvarMgr);
/* Player */
tag = g_ResFactory->GetResourceIdByName("Player");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakPlayer = new DataSpec::DNAMP1::CTweakPlayer(*strm);
g_tweakPlayer->initCVars(cvarMgr);
/* CameraBob */
tag = g_ResFactory->GetResourceIdByName("CameraBob");
@ -60,37 +62,44 @@ void CTweaks::RegisterTweaks()
tag = g_ResFactory->GetResourceIdByName("Ball");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakBall = new DataSpec::DNAMP1::CTweakBall(*strm);
g_tweakBall->initCVars(cvarMgr);
/* PlayerGun */
tag = g_ResFactory->GetResourceIdByName("PlayerGun");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakPlayerGun = new DataSpec::DNAMP1::CTweakPlayerGun(*strm);
g_tweakPlayerGun->initCVars(cvarMgr);
/* Targeting */
tag = g_ResFactory->GetResourceIdByName("Targeting");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakTargeting = new DataSpec::DNAMP1::CTweakTargeting(*strm);
g_tweakTargeting->initCVars(cvarMgr);
/* Game */
tag = g_ResFactory->GetResourceIdByName("Game");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakGame = new DataSpec::DNAMP1::CTweakGame(*strm);
g_tweakGame->initCVars(cvarMgr);
/* GuiColors */
tag = g_ResFactory->GetResourceIdByName("GuiColors");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakGuiColors = new DataSpec::DNAMP1::CTweakGuiColors(*strm);
g_tweakGuiColors->initCVars(cvarMgr);
/* AutoMapper */
tag = g_ResFactory->GetResourceIdByName("AutoMapper");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakAutoMapper = new DataSpec::DNAMP1::CTweakAutoMapper(*strm);
CMappableObject::ReadAutoMapperTweaks(*g_tweakAutoMapper);
g_tweakPlayerGun->initCVars(cvarMgr);
/* Gui */
tag = g_ResFactory->GetResourceIdByName("Gui");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakGui = new DataSpec::DNAMP1::CTweakGui(*strm);
g_tweakPlayerGun->initCVars(cvarMgr);
/* PlayerControls */
tag = g_ResFactory->GetResourceIdByName("PlayerControls");
@ -108,9 +117,11 @@ void CTweaks::RegisterTweaks()
tag = g_ResFactory->GetResourceIdByName("SlideShow");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakSlideShow = new DataSpec::DNAMP1::CTweakSlideShow(*strm);
g_tweakSlideShow->initCVars(cvarMgr);
}
void CTweaks::RegisterResourceTweaks()
void CTweaks::RegisterResourceTweaks(hecl::CVarManager* cvarMgr)
{
std::experimental::optional<CMemoryInStream> strm;
@ -118,11 +129,13 @@ void CTweaks::RegisterResourceTweaks()
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakGunRes = new DataSpec::DNAMP1::CTweakGunRes(*strm);
g_tweakGunRes->ResolveResources(*g_ResFactory);
g_tweakGunRes->initCVars(cvarMgr);
tag = g_ResFactory->GetResourceIdByName("PlayerRes");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakPlayerRes = new DataSpec::DNAMP1::CTweakPlayerRes(*strm);
g_tweakPlayerRes->ResolveResources(*g_ResFactory);
g_tweakPlayerRes->initCVars(cvarMgr);
}
}

View File

@ -2,6 +2,10 @@
#define __URDE_CTWEAKS_HPP__
#include "RetroTypes.hpp"
namespace hecl
{
class CVarManager;
}
namespace urde
{
@ -12,8 +16,8 @@ namespace MP1
class CTweaks
{
public:
void RegisterTweaks();
void RegisterResourceTweaks();
void RegisterTweaks(hecl::CVarManager* cvarMgr);
void RegisterResourceTweaks(hecl::CVarManager* cvarMgr);
};
}

View File

@ -239,11 +239,31 @@ CGameArchitectureSupport::~CGameArchitectureSupport()
CStreamAudioManager::Shutdown();
}
void CGameArchitectureSupport::charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
{
x30_inputGenerator.charKeyDown(charCode, mods, isRepeat);
m_parent.m_console->handleCharCode(charCode, mods, isRepeat);
}
void CGameArchitectureSupport::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
{
x30_inputGenerator.specialKeyDown(key, mods, isRepeat);
m_parent.m_console->handleSpecialKeyDown(key, mods, isRepeat);
}
void CGameArchitectureSupport::specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods)
{
x30_inputGenerator.specialKeyUp(key, mods);
m_parent.m_console->handleSpecialKeyUp(key, mods);
}
CMain::CMain(IFactory* resFactory, CSimplePool* resStore,
boo::IGraphicsDataFactory* gfxFactory,
boo::IGraphicsCommandQueue* cmdQ,
const boo::ObjToken<boo::ITextureR>& spareTex)
: m_booSetter(gfxFactory, cmdQ, spareTex),
: m_booSetter(gfxFactory, cmdQ, spareTex),
x128_globalObjects(resFactory, resStore)
{
xe4_gameplayResult = EGameplayResult::Playing;
@ -418,15 +438,19 @@ void CMain::StreamNewGameState(CBitStreamReader& r, u32 idx)
}
void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
hecl::CVarManager* cvarMgr,
boo::IWindow* window,
boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend)
{
m_mainWindow = window;
m_cvarMgr = cvarMgr;
m_console = std::make_unique<hecl::Console>(m_cvarMgr);
m_console->registerCommand("quit"sv, "Quits the game immediately"sv, ""sv, std::bind(&CMain::quit, this, std::placeholders::_1, std::placeholders::_2));
InitializeSubsystems(storeMgr);
x128_globalObjects.PostInitialize();
x70_tweaks.RegisterTweaks();
x70_tweaks.RegisterResourceTweaks();
x70_tweaks.RegisterTweaks(m_cvarMgr);
x70_tweaks.RegisterResourceTweaks(m_cvarMgr);
AddWorldPaks();
FillInAssetIDs();
x164_archSupport.reset(new CGameArchitectureSupport(*this, voiceEngine, backend));
@ -480,11 +504,16 @@ bool CMain::Proc()
if (m_warmupTags.size())
return false;
CGBASupport::GlobalPoll();
x164_archSupport->UpdateTicks();
x164_archSupport->Update();
CSfxManager::Update(1.f / 60.f);
CStreamAudioManager::Update(1.f / 60.f);
m_console->proc();
if (!m_console->isOpen())
{
CGBASupport::GlobalPoll();
x164_archSupport->UpdateTicks();
x164_archSupport->Update();
CSfxManager::Update(1.f / 60.f);
CStreamAudioManager::Update(1.f / 60.f);
}
if (x164_archSupport->GetIOWinManager().IsEmpty() || CheckReset())
{
CStreamAudioManager::StopAll();
@ -536,6 +565,7 @@ void CMain::Draw()
CGraphics::g_BooMainCommandQueue->clearTarget(true, true);
x164_archSupport->Draw();
m_console->draw(CGraphics::g_BooMainCommandQueue);
}
void CMain::ShutdownSubsystems()

View File

@ -37,6 +37,7 @@
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp"
#include "World/CScriptMazeNode.hpp"
#include "hecl/Console.hpp"
namespace urde
{
@ -122,6 +123,7 @@ class CGameArchitectureSupport : public boo::IWindowCallback
class CGameArchitectureSupport
#endif
{
friend class CMain;
CMain& m_parent;
CArchitectureQueue x4_archQueue;
CAudioSys x0_audioSys;
@ -142,7 +144,7 @@ class CGameArchitectureSupport
boo::SWindowRect m_windowRect;
bool m_rectIsDirty;
void destroyed() { x4_archQueue.Push(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport)); }
void destroyed() { x4_archQueue.Push(MakeMsg::CreateRemoveAllIOWins(EArchMsgTarget::IOWinManager)); }
void resized(const boo::SWindowRect &rect)
{
@ -164,14 +166,11 @@ public:
{ x30_inputGenerator.mouseMove(coord); }
void scroll(const boo::SWindowCoord &coord, const boo::SScrollDelta &scroll)
{ x30_inputGenerator.scroll(coord, scroll); }
void charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
{ x30_inputGenerator.charKeyDown(charCode, mods, isRepeat); }
void charKeyUp(unsigned long charCode, boo::EModifierKey mods)
{ x30_inputGenerator.charKeyUp(charCode, mods); }
void specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
{ x30_inputGenerator.specialKeyDown(key, mods, isRepeat); }
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods)
{ x30_inputGenerator.specialKeyUp(key, mods); }
void charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat);
void charKeyUp(unsigned long charCode, boo::EModifierKey mods) { x30_inputGenerator.charKeyUp(charCode, mods); }
void specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat);
void specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods);
void modKeyDown(boo::EModifierKey mod, bool isRepeat)
{ x30_inputGenerator.modKeyDown(mod, isRepeat);}
void modKeyUp(boo::EModifierKey mod)
@ -255,6 +254,8 @@ private:
boo::IWindow* m_mainWindow = nullptr;
hecl::CVarManager* m_cvarMgr = nullptr;
std::unique_ptr<hecl::Console> m_console;
// Warmup state
std::vector<SObjectTag> m_warmupTags;
std::vector<SObjectTag>::iterator m_warmupIt;
@ -277,6 +278,7 @@ public:
//int RsMain(int argc, const boo::SystemChar* argv[]);
void Init(const hecl::Runtime::FileStoreManager& storeMgr,
hecl::CVarManager* cvarManager,
boo::IWindow* window,
boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend);
@ -312,6 +314,9 @@ public:
CGameArchitectureSupport* GetArchSupport() const { return x164_archSupport.get(); }
size_t GetExpectedIdSize() const { return sizeof(u32); }
void quit(hecl::Console*, const std::vector<std::string>&)
{
}
};
}

2
hecl

@ -1 +1 @@
Subproject commit 38e5245735472af75dec1c8d4df7b6062c16b718
Subproject commit b9f410a2f87eb837ffc5937ed6a7cc637d91ac79

@ -1 +1 @@
Subproject commit c2d4a17ccaca7fb17405cb5a78537b7050d8df04
Subproject commit b9a0bec10b812738cbfdaa14ebef2e570b8c800d