Keyboard/Mouse CFinalInput integration

This commit is contained in:
Jack Andersen 2017-01-22 11:26:58 -10:00
parent 12c6163e32
commit 62dc61bfb2
7 changed files with 101 additions and 30 deletions

View File

@ -43,6 +43,7 @@ public:
hecl::Database::Project* project() {return m_proj.get();}
ProjectResourcePool& objectStore() {return m_objStore;}
ProjectResourceFactoryMP1& resourceFactoryMP1() {return m_factoryMP1;}
MP1::CMain* gameMain() {return m_mainMP1 ? &*m_mainMP1 : nullptr;}
SObjectTag TagFromPath(const hecl::SystemChar* path) const
{ return m_factoryMP1.ProjectResourceFactoryBase::TagFromPath(path); }

View File

@ -298,6 +298,8 @@ void ProjectResourceFactoryBase::BackgroundIndexRecursiveProc(const hecl::Projec
void ProjectResourceFactoryBase::BackgroundIndexProc()
{
logvisor::RegisterThreadName("Resource Index Thread");
hecl::ProjectPath tagCachePath(m_proj->getProjectCookedPath(*m_origSpec), _S("tag_cache.yaml"));
hecl::ProjectPath nameCachePath(m_proj->getProjectCookedPath(*m_origSpec), _S("name_cache.yaml"));
hecl::ProjectPath specRoot(m_proj->getProjectWorkingPath(), m_origSpec->m_name);

View File

@ -55,7 +55,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
m_lineRenderer.reset(new urde::CLineRenderer(urde::CLineRenderer::EPrimitiveMode::LineStrip, 4, nullptr, true));
TLockedToken<CTexture> xrayPalette = objStore.GetObj("TXTR_XRayPalette");
m_particleView.reset(new ParticleView(*this, m_viewResources, *m_rootView, xrayPalette));
m_testGameView.reset(new TestGameView(*this, m_viewResources, *m_rootView, xrayPalette));
#if 0
m_moviePlayer.reset(new CMoviePlayer("Video/SpecialEnding.thp", 1.f, false, true));
@ -74,7 +74,7 @@ void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
//m_newAudioPlayer->StartMixing();
m_rootView->accessContentViews().clear();
m_rootView->accessContentViews().push_back(m_particleView.get());
m_rootView->accessContentViews().push_back(m_testGameView.get());
m_rootView->updateSize();
}
@ -83,13 +83,13 @@ void ViewManager::InitMP1(MP1::CMain& main)
main.Init(m_fileStoreManager, m_voiceEngine.get(), *m_amuseAllocWrapper);
}
void ViewManager::ParticleView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
void ViewManager::TestGameView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
{
specter::View::resized(root, sub);
urde::CGraphics::SetViewportResolution({sub.size[0], sub.size[1]});
}
void ViewManager::ParticleView::draw(boo::IGraphicsCommandQueue *gfxQ)
void ViewManager::TestGameView::draw(boo::IGraphicsCommandQueue *gfxQ)
{
gfxQ->clearTarget(false, true);

View File

@ -50,7 +50,7 @@ class ViewManager : public specter::IViewManager
std::unique_ptr<RootSpace> m_rootSpace;
specter::View* m_rootSpaceView = nullptr;
class ParticleView : public specter::View
class TestGameView : public specter::View
{
ViewManager& m_vm;
CSpaceWarpFilter m_spaceWarpFilter;
@ -61,13 +61,69 @@ class ViewManager : public specter::IViewManager
float m_theta = 0.f;
unsigned m_frame = 0;
public:
ParticleView(ViewManager& vm, specter::ViewResources& res, specter::View& parent,
TestGameView(ViewManager& vm, specter::ViewResources& res, specter::View& parent,
TLockedToken<CTexture>& xrayPalette)
: View(res, parent), m_vm(vm), m_xrayBlur(xrayPalette), m_random(20) {}
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);
void mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mkey)
{
if (MP1::CMain* m = m_vm.m_projManager.gameMain())
if (MP1::CGameArchitectureSupport* as = m->GetArchSupport())
as->mouseDown(coord, button, mkey);
}
void mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mkey)
{
if (MP1::CMain* m = m_vm.m_projManager.gameMain())
if (MP1::CGameArchitectureSupport* as = m->GetArchSupport())
as->mouseUp(coord, button, mkey);
}
void mouseMove(const boo::SWindowCoord& coord)
{
if (MP1::CMain* m = m_vm.m_projManager.gameMain())
if (MP1::CGameArchitectureSupport* as = m->GetArchSupport())
as->mouseMove(coord);
}
void scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& sd)
{
if (MP1::CMain* m = m_vm.m_projManager.gameMain())
if (MP1::CGameArchitectureSupport* as = m->GetArchSupport())
as->scroll(coord, sd);
}
void charKeyDown(unsigned long cc, boo::EModifierKey mkey, bool repeat)
{
if (MP1::CMain* m = m_vm.m_projManager.gameMain())
if (MP1::CGameArchitectureSupport* as = m->GetArchSupport())
as->charKeyDown(cc, mkey, repeat);
}
void charKeyUp(unsigned long cc, boo::EModifierKey mkey)
{
if (MP1::CMain* m = m_vm.m_projManager.gameMain())
if (MP1::CGameArchitectureSupport* as = m->GetArchSupport())
as->charKeyUp(cc, mkey);
}
void specialKeyDown(boo::ESpecialKey skey, boo::EModifierKey mkey, bool repeat)
{
if (MP1::CMain* m = m_vm.m_projManager.gameMain())
if (MP1::CGameArchitectureSupport* as = m->GetArchSupport())
as->specialKeyDown(skey, mkey, repeat);
}
void specialKeyUp(boo::ESpecialKey skey, boo::EModifierKey mkey)
{
if (MP1::CMain* m = m_vm.m_projManager.gameMain())
if (MP1::CGameArchitectureSupport* as = m->GetArchSupport())
as->specialKeyUp(skey, mkey);
}
};
std::unique_ptr<ParticleView> m_particleView;
std::unique_ptr<TestGameView> m_testGameView;
urde::TLockedToken<CModel> m_modelTest;
urde::TLockedToken<CGenDescription> m_partGenDesc;
TLockedToken<CGameHintInfo> m_hints;

View File

@ -405,6 +405,7 @@ struct SDSPStream : boo::IAudioVoiceCallback
if (id == -1)
return -1;
/* -3dB pan law for mono */
stream->AllocateStream(info, vol, 0.707f, 0.707f);
return id;
}

View File

@ -1914,18 +1914,16 @@ void CFrontEndUI::Draw() const
if (xcc_curMoviePtr && xcc_curMoviePtr->GetIsFullyCached())
{
/* Render movie */
auto vidDimensions = xcc_curMoviePtr->GetVideoDimensions();
float aspectRatio = vidDimensions.first / float(vidDimensions.second);
float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
if (vpAspectRatio >= 1.78f)
{
float hPad = 1.78f / vpAspectRatio;
float vPad = 1.78f / aspectRatio;
float vPad = 1.78f / 1.33f;
xcc_curMoviePtr->SetFrame({-hPad, vPad, 0.f}, {-hPad, -vPad, 0.f}, {hPad, -vPad, 0.f}, {hPad, vPad, 0.f});
}
else
{
float vPad = vpAspectRatio / aspectRatio;
float vPad = vpAspectRatio / 1.33f;
xcc_curMoviePtr->SetFrame({-1.f, vPad, 0.f}, {-1.f, -vPad, 0.f}, {1.f, -vPad, 0.f}, {1.f, vPad, 0.f});
}
@ -1951,11 +1949,22 @@ void CFrontEndUI::Draw() const
if (x64_pressStartAlpha > 0.f && x38_pressStart.IsLoaded() && m_pressStartQuad)
{
/* Render "Press Start" */
float nativeRatio = CGraphics::g_ViewportResolution.x / 640.f;
float hOffset = x38_pressStart->GetWidth() / 2.f * nativeRatio;
float vOffset = x38_pressStart->GetHeight() / 2.f * nativeRatio;
zeus::CRectangle rect(CGraphics::g_ViewportResolutionHalf.x - hOffset, 72.f * nativeRatio - vOffset,
x38_pressStart->GetWidth() * nativeRatio, x38_pressStart->GetHeight() * nativeRatio);
float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
float hPad, vPad;
if (vpAspectRatio >= 1.78f)
{
hPad = 1.78f / vpAspectRatio;
vPad = 1.78f / 1.33f;
}
else
{
hPad = 1.f;
vPad = vpAspectRatio / 1.33f;
}
zeus::CRectangle rect(0.5f - x38_pressStart->GetWidth() / 2.f / 640.f * hPad,
0.5f + (x38_pressStart->GetHeight() / 2.f - 240.f + 72.f) / 480.f * vPad,
x38_pressStart->GetWidth() / 640.f * hPad,
x38_pressStart->GetHeight() / 480.f * vPad);
zeus::CColor color = zeus::CColor::skWhite;
color.a = x64_pressStartAlpha;
const_cast<CTexturedQuadFilterAlpha&>(*m_pressStartQuad).draw(color, 1.f, rect);
@ -2046,7 +2055,7 @@ bool CFrontEndUI::PumpLoad()
return false;
/* Ready to construct texture quads */
m_pressStartQuad.emplace(CCameraFilterPass::EFilterType::Blend, x38_pressStart);
m_pressStartQuad.emplace(CCameraFilterPass::EFilterType::Add, x38_pressStart);
return true;
}

View File

@ -125,6 +125,19 @@ class CGameArchitectureSupport
boo::SWindowRect m_windowRect;
bool m_rectIsDirty;
void destroyed() { x4_archQueue.Push(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport)); }
void resized(const boo::SWindowRect &rect)
{
m_windowRect = rect;
m_rectIsDirty = true;
}
public:
CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend);
~CGameArchitectureSupport();
void mouseDown(const boo::SWindowCoord &coord, boo::EMouseButton button, boo::EModifierKey mods)
{ x30_inputGenerator.mouseDown(coord, button, mods); }
void mouseUp(const boo::SWindowCoord &coord, boo::EMouseButton button, boo::EModifierKey mods)
@ -146,19 +159,6 @@ class CGameArchitectureSupport
void modKeyUp(boo::EModifierKey mod)
{ x30_inputGenerator.modKeyUp(mod); }
void destroyed() { x4_archQueue.Push(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport)); }
void resized(const boo::SWindowRect &rect)
{
m_windowRect = rect;
m_rectIsDirty = true;
}
public:
CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend);
~CGameArchitectureSupport();
void PreloadAudio();
bool LoadAudio();
void UnloadAudio();
@ -282,6 +282,8 @@ public:
void SetFlowState(EFlowState s) { x12c_flowState = s; }
void SetX30(bool v) { x160_30_ = v; }
CGameArchitectureSupport* GetArchSupport() const { return x164_archSupport.get(); }
};
}