Bug fixes and CAutoMapper mouse events

This commit is contained in:
Jack Andersen 2019-01-22 21:52:19 -10:00
parent aeb6a9a147
commit 137968ecc7
38 changed files with 275 additions and 118 deletions

View File

@ -731,8 +731,7 @@ void CNESEmulator::Draw(const zeus::CColor& mulColor, bool filtering) {
if (!EmulatorInst) if (!EmulatorInst)
return; return;
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height); float widthFac = NESAspect / g_Viewport.aspect;
float widthFac = NESAspect / aspect;
Uniform uniform = {zeus::CMatrix4f{}, mulColor}; Uniform uniform = {zeus::CMatrix4f{}, mulColor};
uniform.m_matrix[0][0] = widthFac; uniform.m_matrix[0][0] = widthFac;

View File

@ -480,6 +480,41 @@ void CAutoMapper::ProcessMapRotateInput(const CFinalInput& input, const CStateMa
float down = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleDown, input); float down = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleDown, input);
float left = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleLeft, input); float left = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleLeft, input);
float right = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleRight, input); float right = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleRight, input);
bool mouseHeld = false;
if (const auto& kbm = input.GetKBM()) {
if (kbm->m_mouseButtons[int(boo::EMouseButton::Middle)]) {
mouseHeld = true;
if (float(m_mouseDelta.x()) < 0.f)
right += -m_mouseDelta.x();
else if (float(m_mouseDelta.x()) > 0.f)
left += m_mouseDelta.x();
if (float(m_mouseDelta.y()) < 0.f)
up += -m_mouseDelta.y();
else if (float(m_mouseDelta.y()) > 0.f)
down += m_mouseDelta.y();
}
}
float maxMag = up;
int dirSlot = 0;
if (down > up) {
maxMag = down;
dirSlot = 1;
}
if (left > maxMag) {
maxMag = left;
dirSlot = 2;
}
if (right > maxMag) {
maxMag = right;
dirSlot = 3;
}
float dirs[4] = {};
dirs[dirSlot] = maxMag;
if (dirs[0] > 0.f || dirs[1] > 0.f || dirs[2] > 0.f || dirs[3] > 0.f || mouseHeld) {
int flags = 0x0; int flags = 0x0;
if (up > 0.f) if (up > 0.f)
flags |= 0x2; flags |= 0x2;
@ -519,27 +554,8 @@ void CAutoMapper::ProcessMapRotateInput(const CFinalInput& input, const CStateMa
break; break;
} }
float maxMag = up;
int dirSlot = 0;
if (down > up) {
maxMag = down;
dirSlot = 1;
}
if (left > maxMag) {
maxMag = left;
dirSlot = 2;
}
if (right > maxMag) {
maxMag = right;
dirSlot = 3;
}
float dirs[4] = {};
dirs[dirSlot] = maxMag;
if (dirs[0] > 0.f || dirs[1] > 0.f || dirs[2] > 0.f || dirs[3] > 0.f) {
float deltaFrames = input.DeltaTime() * 60.f; float deltaFrames = input.DeltaTime() * 60.f;
SetShouldRotatingSoundBePlaying(true); SetShouldRotatingSoundBePlaying(dirs[0] > 0.f || dirs[1] > 0.f || dirs[2] > 0.f || dirs[3] > 0.f);
zeus::CEulerAngles eulers(xa8_renderStates[0].x8_camOrientation); zeus::CEulerAngles eulers(xa8_renderStates[0].x8_camOrientation);
zeus::CRelAngle angX(eulers.x()); zeus::CRelAngle angX(eulers.x());
angX.makeRel(); angX.makeRel();
@ -571,6 +587,7 @@ void CAutoMapper::ProcessMapRotateInput(const CFinalInput& input, const CStateMa
quat.rotateY(0.f); quat.rotateY(0.f);
xa8_renderStates[0].x8_camOrientation = quat; xa8_renderStates[0].x8_camOrientation = quat;
} else { } else {
x2e4_lStickPos = 0;
SetShouldRotatingSoundBePlaying(false); SetShouldRotatingSoundBePlaying(false);
} }
} }
@ -579,6 +596,18 @@ void CAutoMapper::ProcessMapZoomInput(const CFinalInput& input, const CStateMana
bool in = ControlMapper::GetDigitalInput(ControlMapper::ECommands::MapZoomIn, input); bool in = ControlMapper::GetDigitalInput(ControlMapper::ECommands::MapZoomIn, input);
bool out = ControlMapper::GetDigitalInput(ControlMapper::ECommands::MapZoomOut, input); bool out = ControlMapper::GetDigitalInput(ControlMapper::ECommands::MapZoomOut, input);
if (const auto& kbm = input.GetKBM()) {
m_mapScroll += kbm->m_accumScroll - m_lastAccumScroll;
m_lastAccumScroll = kbm->m_accumScroll;
if (m_mapScroll.delta[1] > 0.0) {
in = true;
m_mapScroll.delta[1] = std::max(0.0, m_mapScroll.delta[1] - (15.0 / 60.0));
} else if (m_mapScroll.delta[1] < 0.0) {
out = true;
m_mapScroll.delta[1] = std::min(0.0, m_mapScroll.delta[1] + (15.0 / 60.0));
}
}
EZoomState nextZoomState = EZoomState::None; EZoomState nextZoomState = EZoomState::None;
switch (x324_zoomState) { switch (x324_zoomState) {
case EZoomState::None: case EZoomState::None:
@ -617,10 +646,7 @@ void CAutoMapper::ProcessMapZoomInput(const CFinalInput& input, const CStateMana
x324_zoomState = EZoomState::Out; x324_zoomState = EZoomState::Out;
} }
if (oldDist == xa8_renderStates[0].x18_camDist) SetShouldZoomingSoundBePlaying(oldDist != xa8_renderStates[0].x18_camDist);
SetShouldZoomingSoundBePlaying(false);
else
SetShouldZoomingSoundBePlaying(true);
} }
void CAutoMapper::ProcessMapPanInput(const CFinalInput& input, const CStateManager& mgr) { void CAutoMapper::ProcessMapPanInput(const CFinalInput& input, const CStateManager& mgr) {
@ -628,8 +654,24 @@ void CAutoMapper::ProcessMapPanInput(const CFinalInput& input, const CStateManag
float back = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapMoveBack, input); float back = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapMoveBack, input);
float left = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapMoveLeft, input); float left = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapMoveLeft, input);
float right = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapMoveRight, input); float right = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapMoveRight, input);
bool mouseHeld = false;
if (const auto& kbm = input.GetKBM()) {
if (kbm->m_mouseButtons[int(boo::EMouseButton::Primary)]) {
mouseHeld = true;
if (float(m_mouseDelta.x()) < 0.f)
right += -m_mouseDelta.x();
else if (float(m_mouseDelta.x()) > 0.f)
left += m_mouseDelta.x();
if (float(m_mouseDelta.y()) < 0.f)
forward += -m_mouseDelta.y();
else if (float(m_mouseDelta.y()) > 0.f)
back += m_mouseDelta.y();
}
}
zeus::CTransform camRot = xa8_renderStates[0].x8_camOrientation.toTransform(); zeus::CTransform camRot = xa8_renderStates[0].x8_camOrientation.toTransform();
if (forward > 0.f || back > 0.f || left > 0.f || right > 0.f) { if (forward > 0.f || back > 0.f || left > 0.f || right > 0.f || mouseHeld) {
float deltaFrames = 60.f * input.DeltaTime(); float deltaFrames = 60.f * input.DeltaTime();
float speed = GetFinalMapScreenCameraMoveSpeed(); float speed = GetFinalMapScreenCameraMoveSpeed();
int flags = 0x0; int flags = 0x0;
@ -674,10 +716,7 @@ void CAutoMapper::ProcessMapPanInput(const CFinalInput& input, const CStateManag
zeus::CVector3f dirVec(right - left, 0.f, forward - back); zeus::CVector3f dirVec(right - left, 0.f, forward - back);
zeus::CVector3f deltaVec = camRot * (dirVec * deltaFrames * speed); zeus::CVector3f deltaVec = camRot * (dirVec * deltaFrames * speed);
zeus::CVector3f newPoint = xa8_renderStates[0].x20_areaPoint + deltaVec; zeus::CVector3f newPoint = xa8_renderStates[0].x20_areaPoint + deltaVec;
if (deltaVec.magnitude() > input.DeltaTime()) SetShouldPanningSoundBePlaying(deltaVec.magnitude() > input.DeltaTime());
SetShouldPanningSoundBePlaying(true);
else
SetShouldPanningSoundBePlaying(false);
if (x1bc_state == EAutoMapperState::MapScreen) { if (x1bc_state == EAutoMapperState::MapScreen) {
xa8_renderStates[0].x20_areaPoint = x24_world->IGetMapWorld()->ConstrainToWorldVolume(newPoint, camRot.basis[1]); xa8_renderStates[0].x20_areaPoint = x24_world->IGetMapWorld()->ConstrainToWorldVolume(newPoint, camRot.basis[1]);
@ -688,6 +727,7 @@ void CAutoMapper::ProcessMapPanInput(const CFinalInput& input, const CStateManag
xa8_renderStates[0].x20_areaPoint = newPoint; xa8_renderStates[0].x20_areaPoint = newPoint;
} }
} else { } else {
x2e8_rStickPos = 0;
SetShouldPanningSoundBePlaying(false); SetShouldPanningSoundBePlaying(false);
float speed = g_tweakAutoMapper->GetCamPanUnitsPerFrame() * GetBaseMapScreenCameraMoveSpeed(); float speed = g_tweakAutoMapper->GetCamPanUnitsPerFrame() * GetBaseMapScreenCameraMoveSpeed();
if (x1bc_state == EAutoMapperState::MapScreen) { if (x1bc_state == EAutoMapperState::MapScreen) {
@ -764,11 +804,22 @@ void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, const CStateMa
if (input.PA() || input.PSpecialKey(boo::ESpecialKey::Enter)) if (input.PA() || input.PSpecialKey(boo::ESpecialKey::Enter))
x2f4_aButtonPos = 1; x2f4_aButtonPos = 1;
if (IsInMapperState(EAutoMapperState::MapScreen) || IsInMapperState(EAutoMapperState::MapScreenUniverse)) { if (IsInPlayerControlState()) {
x2e4_lStickPos = 0;
x2e8_rStickPos = 0;
x2ec_lTriggerPos = 0; x2ec_lTriggerPos = 0;
x2f0_rTriggerPos = 0; x2f0_rTriggerPos = 0;
if (const auto& kbm = input.GetKBM()) {
zeus::CVector2f mouseCoord = zeus::CVector2f(kbm->m_mouseCoord.norm[0], kbm->m_mouseCoord.norm[1]);
if (!m_lastMouseCoord) {
m_lastMouseCoord.emplace(mouseCoord);
} else {
m_mouseDelta = mouseCoord - *m_lastMouseCoord;
m_lastMouseCoord.emplace(mouseCoord);
m_mouseDelta.x() *= g_Viewport.aspect;
m_mouseDelta *= 100.f;
}
}
ProcessMapRotateInput(input, mgr); ProcessMapRotateInput(input, mgr);
ProcessMapZoomInput(input, mgr); ProcessMapZoomInput(input, mgr);
ProcessMapPanInput(input, mgr); ProcessMapPanInput(input, mgr);
@ -919,6 +970,12 @@ float CAutoMapper::GetClampedMapScreenCameraDistance(float v) {
return zeus::clamp(g_tweakAutoMapper->GetMinCamDist(), v, g_tweakAutoMapper->GetMaxCamDist()); return zeus::clamp(g_tweakAutoMapper->GetMinCamDist(), v, g_tweakAutoMapper->GetMaxCamDist());
} }
void CAutoMapper::MuteAllLoopedSounds() {
CSfxManager::SfxVolume(x1cc_panningSfx, 0.f);
CSfxManager::SfxVolume(x1d0_rotatingSfx, 0.f);
CSfxManager::SfxVolume(x1d4_zoomingSfx, 0.f);
}
void CAutoMapper::UnmuteAllLoopedSounds() { void CAutoMapper::UnmuteAllLoopedSounds() {
CSfxManager::SfxVolume(x1cc_panningSfx, 1.f); CSfxManager::SfxVolume(x1cc_panningSfx, 1.f);
CSfxManager::SfxVolume(x1d0_rotatingSfx, 1.f); CSfxManager::SfxVolume(x1d0_rotatingSfx, 1.f);
@ -927,7 +984,7 @@ void CAutoMapper::UnmuteAllLoopedSounds() {
void CAutoMapper::ProcessControllerInput(const CFinalInput& input, CStateManager& mgr) { void CAutoMapper::ProcessControllerInput(const CFinalInput& input, CStateManager& mgr) {
if (!IsRenderStateInterpolating()) { if (!IsRenderStateInterpolating()) {
if (IsInMapperState(EAutoMapperState::MapScreen) || IsInMapperState(EAutoMapperState::MapScreenUniverse)) { if (IsInPlayerControlState()) {
if (x32c_loadingDummyWorld) if (x32c_loadingDummyWorld)
CheckDummyWorldLoad(mgr); CheckDummyWorldLoad(mgr);
else if (x1e0_hintSteps.size()) else if (x1e0_hintSteps.size())
@ -1003,7 +1060,7 @@ void CAutoMapper::ProcessControllerInput(const CFinalInput& input, CStateManager
} }
} }
if (input.PY()) { if (input.PY() || input.PKey(' ')) {
CPersistentOptions& sysOpts = g_GameState->SystemOptions(); CPersistentOptions& sysOpts = g_GameState->SystemOptions();
switch (sysOpts.GetAutoMapperKeyState()) { switch (sysOpts.GetAutoMapperKeyState()) {
case 0: case 0:
@ -1110,7 +1167,7 @@ void CAutoMapper::Update(float dt, const CStateManager& mgr) {
x320_bottomPanePos = std::max(0.f, std::min(x320_bottomPanePos, 1.f)); x320_bottomPanePos = std::max(0.f, std::min(x320_bottomPanePos, 1.f));
if (x30c_basewidget_leftPane) { if (x30c_basewidget_leftPane) {
float vpAspectRatio = std::max(1.78f, g_Viewport.x8_width / float(g_Viewport.xc_height)); float vpAspectRatio = std::max(1.78f, g_Viewport.aspect);
x30c_basewidget_leftPane->SetLocalTransform( x30c_basewidget_leftPane->SetLocalTransform(
zeus::CTransform::Translate(x318_leftPanePos * vpAspectRatio * -9.f, 0.f, 0.f) * zeus::CTransform::Translate(x318_leftPanePos * vpAspectRatio * -9.f, 0.f, 0.f) *
x30c_basewidget_leftPane->GetTransform()); x30c_basewidget_leftPane->GetTransform());

View File

@ -172,6 +172,11 @@ private:
u32 x328_ = 0; u32 x328_ = 0;
bool x32c_loadingDummyWorld = false; bool x32c_loadingDummyWorld = false;
std::experimental::optional<zeus::CVector2f> m_lastMouseCoord;
zeus::CVector2f m_mouseDelta;
boo::SScrollDelta m_lastAccumScroll;
boo::SScrollDelta m_mapScroll;
template <class T> template <class T>
static void SetResLockState(T& list, bool lock) { static void SetResLockState(T& list, bool lock) {
for (auto& res : list) for (auto& res : list)
@ -215,20 +220,20 @@ public:
CAutoMapper(CStateManager& stateMgr); CAutoMapper(CStateManager& stateMgr);
bool CheckLoadComplete(); bool CheckLoadComplete();
bool CanLeaveMapScreen(const CStateManager&) const; bool CanLeaveMapScreen(const CStateManager&) const;
float GetMapRotationX() const; float GetMapRotationX() const { return xa8_renderStates[0].x1c_camAngle; }
float GetMapRotationZ() const; float GetMapRotationZ() const { return xa8_renderStates[0].x8_camOrientation.yaw(); }
u32 GetFocusAreaIndex() const; TAreaId GetFocusAreaIndex() const { return xa0_curAreaId; }
CAssetId GetCurrWorldAssetId() const; CAssetId GetCurrWorldAssetId() const { return x24_world->IGetWorldAssetId(); }
void SetCurWorldAssetId(CAssetId mlvlId); void SetCurWorldAssetId(CAssetId mlvlId);
void MuteAllLoopedSounds(); void MuteAllLoopedSounds();
void UnmuteAllLoopedSounds(); void UnmuteAllLoopedSounds();
void ProcessControllerInput(const CFinalInput&, CStateManager&); void ProcessControllerInput(const CFinalInput&, CStateManager&);
bool IsInPlayerControlState() const; bool IsInPlayerControlState() const {
return IsInMapperState(EAutoMapperState::MapScreen) || IsInMapperState(EAutoMapperState::MapScreenUniverse);
}
void Update(float dt, const CStateManager& mgr); void Update(float dt, const CStateManager& mgr);
void Draw(const CStateManager&, const zeus::CTransform&, float) const; void Draw(const CStateManager&, const zeus::CTransform&, float) const;
bool IsInOrTransitioningToMapScreenState() const; float GetTimeIntoInterpolation() const { return x1c8_interpTime; }
float GetTimeIntoInterpolation() const;
bool IsFullyInMapScreenState() const;
void BeginMapperStateTransition(EAutoMapperState, const CStateManager&); void BeginMapperStateTransition(EAutoMapperState, const CStateManager&);
void CompleteMapperStateTransition(const CStateManager&); void CompleteMapperStateTransition(const CStateManager&);
void ResetInterpolationTimer(float); void ResetInterpolationTimer(float);

View File

@ -610,8 +610,7 @@ void CStateManager::ResetViewAfterDraw(const SViewport& backupViewport,
const CGameCamera* cam = x870_cameraManager->GetCurrentCamera(*this); const CGameCamera* cam = x870_cameraManager->GetCurrentCamera(*this);
zeus::CFrustum frustum; zeus::CFrustum frustum;
frustum.updatePlanes(backupViewMatrix, zeus::SProjPersp(zeus::degToRad(cam->GetFov()), frustum.updatePlanes(backupViewMatrix, zeus::SProjPersp(zeus::degToRad(cam->GetFov()), g_Viewport.aspect,
g_Viewport.x8_width / float(g_Viewport.xc_height),
cam->GetNearClipDistance(), cam->GetFarClipDistance())); cam->GetNearClipDistance(), cam->GetFarClipDistance()));
g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetClippingPlanes(frustum);

View File

@ -393,6 +393,7 @@ void CGraphics::SetViewportResolution(const zeus::CVector2i& res) {
g_CroppedViewport.x10_height = res.y; g_CroppedViewport.x10_height = res.y;
g_Viewport.x10_halfWidth = res.x / 2.f; g_Viewport.x10_halfWidth = res.x / 2.f;
g_Viewport.x14_halfHeight = res.y / 2.f; g_Viewport.x14_halfHeight = res.y / 2.f;
g_Viewport.aspect = res.x / float(res.y);
if (g_GuiSys) if (g_GuiSys)
g_GuiSys->OnViewportResize(); g_GuiSys->OnViewportResize();
} }

View File

@ -103,6 +103,7 @@ struct SViewport {
u32 xc_height; u32 xc_height;
float x10_halfWidth; float x10_halfWidth;
float x14_halfHeight; float x14_halfHeight;
float aspect;
}; };
extern SViewport g_Viewport; extern SViewport g_Viewport;

View File

@ -15,11 +15,13 @@ float CLight::CalculateLightRadius() const {
if (x2c_distQ > FLT_EPSILON) { if (x2c_distQ > FLT_EPSILON) {
if (intens <= FLT_EPSILON) if (intens <= FLT_EPSILON)
return 0.f; return 0.f;
return std::sqrt(intens / 5.f * intens / 255.f * x2c_distQ); return std::sqrt(intens / (0.0588235f * x2c_distQ));
} }
float nextIntens = 5.f * intens / 255.f; if (x28_distL > FLT_EPSILON)
return intens / std::min(0.2f, nextIntens) * x28_distL; return intens / (0.0588235f * x28_distL);
return 0.f;
} }
float CLight::GetIntensity() const { float CLight::GetIntensity() const {

View File

@ -66,8 +66,7 @@ void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle&
} }
void CWideScreenFilter::draw(const zeus::CColor& color, float t) { void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height); if (g_Viewport.aspect < 1.7777f) {
if (aspect < 1.7777f) {
float targetHeight = g_Viewport.x8_width / 1.7777f; float targetHeight = g_Viewport.x8_width / 1.7777f;
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f; float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
delta /= float(g_Viewport.xc_height); delta /= float(g_Viewport.xc_height);
@ -81,8 +80,7 @@ void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
void CWideScreenFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t) {} void CWideScreenFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t) {}
float CWideScreenFilter::SetViewportToMatch(float t) { float CWideScreenFilter::SetViewportToMatch(float t) {
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height); if (g_Viewport.aspect < 1.7777f) {
if (aspect < 1.7777f) {
float targetHeight = g_Viewport.x8_width / 1.7777f; float targetHeight = g_Viewport.x8_width / 1.7777f;
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f; float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f;
boo::SWindowRect rect = {}; boo::SWindowRect rect = {};
@ -94,7 +92,7 @@ float CWideScreenFilter::SetViewportToMatch(float t) {
return 1.7777f; return 1.7777f;
} else { } else {
SetViewportToFull(); SetViewportToFull();
return aspect; return g_Viewport.aspect;
} }
} }

View File

@ -84,10 +84,10 @@ FOG_STRUCT_GLSL
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n" " float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
" lights[i].angAtt[1] * angDot +\n" " lights[i].angAtt[1] * angDot +\n"
" lights[i].angAtt[0];\n" " lights[i].angAtt[0];\n"
" ret += lights[i].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0);\n" " ret += lights[i].color * angAtt * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0);\n"
" }\n" " }\n"
" \n" " \n"
" return ret;\n" " return clamp(ret, 0.0, 1.0);\n"
"}\n"sv; "}\n"sv;
static std::string_view LightingShadowGLSL = static std::string_view LightingShadowGLSL =

View File

@ -83,7 +83,7 @@ FOG_STRUCT_HLSL
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n" " float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
" lights[i].angAtt[1] * angDot +\n" " lights[i].angAtt[1] * angDot +\n"
" lights[i].angAtt[0];\n" " lights[i].angAtt[0];\n"
" ret += lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn));\n" " ret += lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" }\n" " }\n"
" \n" " \n"
" return ret;\n" " return ret;\n"

View File

@ -83,7 +83,7 @@ FOG_STRUCT_METAL
" float angAtt = lu.lights[i].angAtt[2] * angDot * angDot +\n" " float angAtt = lu.lights[i].angAtt[2] * angDot * angDot +\n"
" lu.lights[i].angAtt[1] * angDot +\n" " lu.lights[i].angAtt[1] * angDot +\n"
" lu.lights[i].angAtt[0];\n" " lu.lights[i].angAtt[0];\n"
" ret += lu.lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn));\n" " ret += lu.lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" }\n" " }\n"
" \n" " \n"
" return ret;\n" " return ret;\n"

View File

@ -40,7 +40,6 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
{{1.f, -1.f, 0.f}, {1.f, 0.f}}}; {{1.f, -1.f, 0.f}, {1.f, 0.f}}};
m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts, sizeof(BlurVert), 4); m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts, sizeof(BlurVert), 4);
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height);
struct Vert { struct Vert {
zeus::CVector3f pos; zeus::CVector3f pos;
zeus::CVector2f screenUv; zeus::CVector2f screenUv;
@ -48,8 +47,8 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
zeus::CVector2f maskUv; zeus::CVector2f maskUv;
} verts[4] = {{{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}}, } verts[4] = {{{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}},
{{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}}, {{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}},
{{1.f, 1.f, 0.f}, {0.99f, 0.99f}, {aspect * 4.f, 4.f}, {1.f, 1.f}}, {{1.f, 1.f, 0.f}, {0.99f, 0.99f}, {g_Viewport.aspect * 4.f, 4.f}, {1.f, 1.f}},
{{1.f, -1.f, 0.f}, {0.99f, 0.01f}, {aspect * 4.f, 0.f}, {1.f, 0.f}}}; {{1.f, -1.f, 0.f}, {0.99f, 0.01f}, {g_Viewport.aspect * 4.f, 0.f}, {1.f, 0.f}}};
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4); m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBufBlurX.get()}; boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBufBlurX.get()};

View File

@ -232,8 +232,6 @@ bool CGuiFrame::ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDraw
m_inMouseDown = false; m_inMouseDown = false;
m_inCancel = false; m_inCancel = false;
if (m_mouseDownWidget == m_lastMouseOverWidget) { if (m_mouseDownWidget == m_lastMouseOverWidget) {
if (m_mouseUpCb)
m_mouseUpCb(m_mouseDownWidget, false);
if (m_mouseDownWidget) { if (m_mouseDownWidget) {
if (CGuiTableGroup* p = static_cast<CGuiTableGroup*>(m_mouseDownWidget->GetParent())) { if (CGuiTableGroup* p = static_cast<CGuiTableGroup*>(m_mouseDownWidget->GetParent())) {
if (p->GetWidgetTypeID() == FOURCC('TBGP')) { if (p->GetWidgetTypeID() == FOURCC('TBGP')) {
@ -243,12 +241,21 @@ bool CGuiFrame::ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDraw
} }
} }
} }
if (m_mouseUpCb)
m_mouseUpCb(m_mouseDownWidget, false);
} }
} }
} }
return false; return false;
} }
void CGuiFrame::ResetMouseState() {
m_inMouseDown = false;
m_inCancel = false;
m_mouseDownWidget = nullptr;
m_lastMouseOverWidget = nullptr;
}
std::unique_ptr<CGuiFrame> CGuiFrame::CreateFrame(CAssetId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp) { std::unique_ptr<CGuiFrame> CGuiFrame::CreateFrame(CAssetId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp) {
in.readInt32Big(); in.readInt32Big();
int a = in.readInt32Big(); int a = in.readInt32Big();

View File

@ -96,6 +96,7 @@ public:
void LoadWidgetsInGame(CInputStream& in, CSimplePool* sp); void LoadWidgetsInGame(CInputStream& in, CSimplePool* sp);
void ProcessUserInput(const CFinalInput& input) const; void ProcessUserInput(const CFinalInput& input) const;
bool ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDrawParms& parms) const; bool ProcessMouseInput(const CFinalInput& input, const CGuiWidgetDrawParms& parms) const;
void ResetMouseState();
CGuiWidgetIdDB& GetWidgetIdDB() { return x18_idDB; } CGuiWidgetIdDB& GetWidgetIdDB() { return x18_idDB; }

View File

@ -74,20 +74,19 @@ void CGuiSys::OnViewportResize() {
} }
void CGuiSys::ViewportResizeFrame(CGuiFrame* frame) { void CGuiSys::ViewportResizeFrame(CGuiFrame* frame) {
float vpAspectRatio = g_Viewport.x8_width / float(g_Viewport.xc_height);
if (frame->m_aspectConstraint > 0.f) { if (frame->m_aspectConstraint > 0.f) {
float hPad, vPad; float hPad, vPad;
if (vpAspectRatio >= frame->m_aspectConstraint) { if (g_Viewport.aspect >= frame->m_aspectConstraint) {
hPad = frame->m_aspectConstraint / vpAspectRatio; hPad = frame->m_aspectConstraint / g_Viewport.aspect;
vPad = frame->m_aspectConstraint / 1.38f; vPad = frame->m_aspectConstraint / 1.38f;
} else { } else {
hPad = 1.f; hPad = 1.f;
vPad = vpAspectRatio / 1.38f; vPad = g_Viewport.aspect / 1.38f;
} }
frame->m_aspectTransform = zeus::CTransform::Scale({hPad, 1.f, vPad}); frame->m_aspectTransform = zeus::CTransform::Scale({hPad, 1.f, vPad});
} else if (frame->m_maxAspect > 0.f) { } else if (frame->m_maxAspect > 0.f) {
if (vpAspectRatio > frame->m_maxAspect) if (g_Viewport.aspect > frame->m_maxAspect)
frame->m_aspectTransform = zeus::CTransform::Scale({frame->m_maxAspect / vpAspectRatio, 1.f, 1.f}); frame->m_aspectTransform = zeus::CTransform::Scale({frame->m_maxAspect / g_Viewport.aspect, 1.f, 1.f});
else else
frame->m_aspectTransform = zeus::CTransform::Identity(); frame->m_aspectTransform = zeus::CTransform::Identity();
} }

View File

@ -72,7 +72,7 @@ void COrbitPointMarker::Draw(const CStateManager& mgr) const {
CGraphics::SetViewPointMatrix(camXf); CGraphics::SetViewPointMatrix(camXf);
zeus::CFrustum frustum = mgr.SetupDrawFrustum(g_Viewport); zeus::CFrustum frustum = mgr.SetupDrawFrustum(g_Viewport);
frustum.updatePlanes(camXf, zeus::SProjPersp(zeus::degToRad(curCam->GetFov()), frustum.updatePlanes(camXf, zeus::SProjPersp(zeus::degToRad(curCam->GetFov()),
g_Viewport.x8_width / float(g_Viewport.xc_height), 1.f, 100.f)); g_Viewport.aspect, 1.f, 100.f));
g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetClippingPlanes(frustum);
g_Renderer->SetPerspective(curCam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, g_Renderer->SetPerspective(curCam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height,
curCam->GetNearClipDistance(), curCam->GetFarClipDistance()); curCam->GetNearClipDistance(), curCam->GetFarClipDistance());

View File

@ -60,8 +60,7 @@ void CSplashScreen::Draw() const {
color.a() = x18_splashTimeout * 2.f; color.a() = x18_splashTimeout * 2.f;
zeus::CRectangle rect; zeus::CRectangle rect;
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height); rect.size.x() = m_quad.GetTex()->GetWidth() / (480.f * g_Viewport.aspect);
rect.size.x() = m_quad.GetTex()->GetWidth() / (480.f * aspect);
rect.size.y() = m_quad.GetTex()->GetHeight() / 480.f; rect.size.y() = m_quad.GetTex()->GetHeight() / 480.f;
rect.position.x() = 0.5f - rect.size.x() / 2.f; rect.position.x() = 0.5f - rect.size.x() / 2.f;
rect.position.y() = 0.5f - rect.size.y() / 2.f; rect.position.y() = 0.5f - rect.size.y() / 2.f;

View File

@ -26,7 +26,7 @@ void CTargetingManager::Draw(const CStateManager& mgr, bool hideLockon) const {
CGraphics::SetViewPointMatrix(camXf); CGraphics::SetViewPointMatrix(camXf);
zeus::CFrustum frustum; zeus::CFrustum frustum;
frustum.updatePlanes(camXf, zeus::SProjPersp(zeus::degToRad(curCam->GetFov()), frustum.updatePlanes(camXf, zeus::SProjPersp(zeus::degToRad(curCam->GetFov()),
g_Viewport.x8_width / float(g_Viewport.xc_height), 1.f, 100.f)); g_Viewport.aspect, 1.f, 100.f));
g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetClippingPlanes(frustum);
g_Renderer->SetPerspective(curCam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, curCam->GetNearClipDistance(), g_Renderer->SetPerspective(curCam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, curCam->GetNearClipDistance(),
curCam->GetFarClipDistance()); curCam->GetFarClipDistance());

View File

@ -1359,7 +1359,7 @@ void CFrontEndUI::SNesEmulatorFrame::Draw(CSaveGameScreen* saveUi) const {
if (x10_remTime <= 0.f) if (x10_remTime <= 0.f)
return; return;
if (xc_textSupport->GetIsTextSupportFinishedLoading()) { if (xc_textSupport->GetIsTextSupportFinishedLoading()) {
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height) / 1.33f; float aspect = g_Viewport.aspect / 1.33f;
CGraphics::SetOrtho(-320.f * aspect, 320.f * aspect, 240.f, -240.f, -4096.f, 4096.f); CGraphics::SetOrtho(-320.f * aspect, 320.f * aspect, 240.f, -240.f, -4096.f, 4096.f);
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity()); CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
CGraphics::SetModelMatrix(zeus::CTransform::Translate(-220.f, 0.f, -200.f)); CGraphics::SetModelMatrix(zeus::CTransform::Translate(-220.f, 0.f, -200.f));
@ -1873,14 +1873,13 @@ void CFrontEndUI::Draw() const {
g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f); g_Renderer->SetViewportOrtho(false, -4096.f, 4096.f);
/* Correct movie aspect ratio */ /* Correct movie aspect ratio */
float vpAspectRatio = g_Viewport.x8_width / float(g_Viewport.xc_height);
float hPad, vPad; float hPad, vPad;
if (vpAspectRatio >= 1.78f) { if (g_Viewport.aspect >= 1.78f) {
hPad = 1.78f / vpAspectRatio; hPad = 1.78f / g_Viewport.aspect;
vPad = 1.78f / 1.33f; vPad = 1.78f / 1.33f;
} else { } else {
hPad = 1.f; hPad = 1.f;
vPad = vpAspectRatio / 1.33f; vPad = g_Viewport.aspect / 1.33f;
} }
if (xcc_curMoviePtr && xcc_curMoviePtr->GetIsFullyCached()) { if (xcc_curMoviePtr && xcc_curMoviePtr->GetIsFullyCached()) {

View File

@ -116,8 +116,17 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
return; return;
float absViewInterp = std::fabs(viewInterp); float absViewInterp = std::fabs(viewInterp);
if (input.PY() && x19c_samusDoll->IsLoaded() && (absViewInterp > 0.f || x10_mode != EMode::TextScroll)) if ((input.PY() || ((m_bodyUpClicked || m_bodyClicked) && absViewInterp == 0.f)) &&
x19c_samusDoll->IsLoaded() && (absViewInterp > 0.f || x10_mode != EMode::TextScroll)) {
x19c_samusDoll->BeginViewInterpolate(absViewInterp == 0.f); x19c_samusDoll->BeginViewInterpolate(absViewInterp == 0.f);
if (absViewInterp == 0.f) {
if (const auto& kbm = input.GetKBM()) {
m_lastMouseCoord = zeus::CVector2f(kbm->m_mouseCoord.norm[0], kbm->m_mouseCoord.norm[1]);
m_lastAccumScroll = kbm->m_accumScroll;
m_dollScroll = boo::SScrollDelta();
}
}
}
if (absViewInterp == 1.f) { if (absViewInterp == 1.f) {
if (input.PStart()) { if (input.PStart()) {
@ -129,6 +138,8 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
} }
if (std::fabs(x19c_samusDoll->GetViewInterpolation()) > 0.f) { if (std::fabs(x19c_samusDoll->GetViewInterpolation()) > 0.f) {
CPauseScreenBase::ResetMouseState();
float motionAmt = input.DeltaTime() * 6.f; float motionAmt = input.DeltaTime() * 6.f;
float circleUp = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleUp, input); float circleUp = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleUp, input);
float circleDown = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleDown, input); float circleDown = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapCircleDown, input);
@ -141,6 +152,48 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
float zoomIn = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapZoomIn, input); float zoomIn = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapZoomIn, input);
float zoomOut = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapZoomOut, input); float zoomOut = ControlMapper::GetAnalogInput(ControlMapper::ECommands::MapZoomOut, input);
if (const auto& kbm = input.GetKBM()) {
zeus::CVector2f mouseCoord = zeus::CVector2f(kbm->m_mouseCoord.norm[0], kbm->m_mouseCoord.norm[1]);
zeus::CVector2f mouseDelta = mouseCoord - m_lastMouseCoord;
m_lastMouseCoord = mouseCoord;
mouseDelta.x() *= g_Viewport.aspect;
mouseDelta *= 100.f;
if (kbm->m_mouseButtons[int(boo::EMouseButton::Primary)]) {
if (float(mouseDelta.x()) < 0.f)
moveRight += -mouseDelta.x();
else if (float(mouseDelta.x()) > 0.f)
moveLeft += mouseDelta.x();
if (float(mouseDelta.y()) < 0.f)
moveForward += -mouseDelta.y();
else if (float(mouseDelta.y()) > 0.f)
moveBack += mouseDelta.y();
}
if (kbm->m_mouseButtons[int(boo::EMouseButton::Middle)]) {
if (float(mouseDelta.x()) < 0.f)
circleRight += -mouseDelta.x();
else if (float(mouseDelta.x()) > 0.f)
circleLeft += mouseDelta.x();
if (float(mouseDelta.y()) < 0.f)
circleUp += -mouseDelta.y();
else if (float(mouseDelta.y()) > 0.f)
circleDown += mouseDelta.y();
}
m_dollScroll += kbm->m_accumScroll - m_lastAccumScroll;
m_lastAccumScroll = kbm->m_accumScroll;
if (m_dollScroll.delta[1] > 0.0) {
zoomIn = 1.f;
m_dollScroll.delta[1] = std::max(0.0, m_dollScroll.delta[1] - (15.0 / 60.0));
} else if (m_dollScroll.delta[1] < 0.0) {
if (x19c_samusDoll->IsZoomedOut()) {
x19c_samusDoll->BeginViewInterpolate(false);
return;
}
zoomOut = 1.f;
m_dollScroll.delta[1] = std::min(0.0, m_dollScroll.delta[1] + (15.0 / 60.0));
}
}
zeus::CVector3f moveVec = {(moveRight - moveLeft) * 0.25f * motionAmt, (zoomIn - zoomOut) * 0.5f * motionAmt, zeus::CVector3f moveVec = {(moveRight - moveLeft) * 0.25f * motionAmt, (zoomIn - zoomOut) * 0.5f * motionAmt,
(moveForward - moveBack) * 0.25f * motionAmt}; (moveForward - moveBack) * 0.25f * motionAmt};
x19c_samusDoll->SetOffset(moveVec, input.DeltaTime()); x19c_samusDoll->SetOffset(moveVec, input.DeltaTime());

View File

@ -19,6 +19,10 @@ class CInventoryScreen : public CPauseScreenBase {
bool x1ac_textLeaveRequested = false; bool x1ac_textLeaveRequested = false;
bool x1ad_textViewing; bool x1ad_textViewing;
zeus::CVector2f m_lastMouseCoord;
boo::SScrollDelta m_lastAccumScroll;
boo::SScrollDelta m_dollScroll;
void UpdateSamusDollPulses(); void UpdateSamusDollPulses();
bool HasLeftInventoryItem(int idx) const; bool HasLeftInventoryItem(int idx) const;
bool HasRightInventoryItem(int idx) const; bool HasRightInventoryItem(int idx) const;

View File

@ -147,13 +147,17 @@ void COptionsScreen::Touch() {
void COptionsScreen::ProcessControllerInput(const CFinalInput& input) { void COptionsScreen::ProcessControllerInput(const CFinalInput& input) {
if (!x19c_quitGame) { if (!x19c_quitGame) {
bool leftClicked = m_leftClicked;
bool rightClicked = m_rightClicked;
CPauseScreenBase::ProcessMouseInput(input, 0.f); CPauseScreenBase::ProcessMouseInput(input, 0.f);
CPauseScreenBase::ProcessControllerInput(input); CPauseScreenBase::ProcessControllerInput(input);
CGameOptions::TryRestoreDefaults(input, x70_tablegroup_leftlog->GetUserSelection(), x1c_rightSel, false, false); CGameOptions::TryRestoreDefaults(input, x70_tablegroup_leftlog->GetUserSelection(), x1c_rightSel, false,
if (x70_tablegroup_leftlog->GetUserSelection() == 4 && (input.PA() || rightClicked);
if (x70_tablegroup_leftlog->GetUserSelection() == 4 && (input.PA() || leftClicked ||
input.PSpecialKey(boo::ESpecialKey::Enter))) input.PSpecialKey(boo::ESpecialKey::Enter)))
x19c_quitGame = std::make_unique<CQuitGameScreen>(EQuitType::QuitGame); x19c_quitGame = std::make_unique<CQuitGameScreen>(EQuitType::QuitGame);
} else { } else {
CPauseScreenBase::ResetMouseState();
x19c_quitGame->ProcessUserInput(input); x19c_quitGame->ProcessUserInput(input);
} }
} }

View File

@ -223,9 +223,11 @@ void CPauseScreen::ProcessControllerInput(const CStateManager& mgr, const CFinal
} }
x38_textpane_l1->TextSupport().SetText( x38_textpane_l1->TextSupport().SetText(
hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x74_lTrigger[useInput.DLTrigger() || m_lDown].Value()))); hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x74_lTrigger[
ControlMapper::GetDigitalInput(ControlMapper::ECommands::PreviousPauseScreen, useInput) || m_lDown].Value())));
x3c_textpane_r->TextSupport().SetText( x3c_textpane_r->TextSupport().SetText(
hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x80_rTrigger[useInput.DRTrigger() || m_rDown].Value()))); hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x80_rTrigger[
ControlMapper::GetDigitalInput(ControlMapper::ECommands::NextPauseScreen, useInput) || m_rDown].Value())));
x48_textpane_return->TextSupport().SetText( x48_textpane_return->TextSupport().SetText(
hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x8c_startButton[useInput.DStart() || m_returnDown].Value()))); hecl::Format("&image=%8.8X;", u32(g_tweakPlayerRes->x8c_startButton[useInput.DStart() || m_returnDown].Value())));
x50_textpane_back->TextSupport().SetText( x50_textpane_back->TextSupport().SetText(

View File

@ -329,10 +329,21 @@ bool CPauseScreenBase::ProcessMouseInput(const CFinalInput& input, float yOff) {
m_bodyUpClicked = false; m_bodyUpClicked = false;
m_bodyDownClicked = false; m_bodyDownClicked = false;
m_bodyClicked = false; m_bodyClicked = false;
m_leftClicked = false;
m_rightClicked = false;
CGuiWidgetDrawParms parms(1.f, zeus::CVector3f{0.f, 15.f * yOff, 0.f}); CGuiWidgetDrawParms parms(1.f, zeus::CVector3f{0.f, 15.f * yOff, 0.f});
return x8_frame.ProcessMouseInput(input, parms); return x8_frame.ProcessMouseInput(input, parms);
} }
void CPauseScreenBase::ResetMouseState() {
m_bodyUpClicked = false;
m_bodyDownClicked = false;
m_bodyClicked = false;
m_leftClicked = false;
m_rightClicked = false;
x8_frame.ResetMouseState();
}
void CPauseScreenBase::Draw(float mainAlpha, float frameAlpha, float yOff) { void CPauseScreenBase::Draw(float mainAlpha, float frameAlpha, float yOff) {
zeus::CColor color = zeus::CColor::skWhite; zeus::CColor color = zeus::CColor::skWhite;
color.a() = mainAlpha * x14_alpha; color.a() = mainAlpha * x14_alpha;
@ -415,6 +426,7 @@ void CPauseScreenBase::OnWidgetMouseUp(CGuiWidget* widget, bool cancel) {
/* Simulate change to right table if able */ /* Simulate change to right table if able */
if (ShouldLeftTableAdvance()) if (ShouldLeftTableAdvance())
ChangeMode(EMode::RightTable, false); ChangeMode(EMode::RightTable, false);
m_leftClicked = true;
} }
} else if (widget->GetParent() == x84_tablegroup_rightlog) { } else if (widget->GetParent() == x84_tablegroup_rightlog) {
if (m_isLogBook && x10_mode == EMode::TextScroll) if (m_isLogBook && x10_mode == EMode::TextScroll)
@ -439,6 +451,7 @@ void CPauseScreenBase::OnWidgetMouseUp(CGuiWidget* widget, bool cancel) {
m_playRightTableSfx = true; m_playRightTableSfx = true;
/* Simulate change to text scroll if able */ /* Simulate change to text scroll if able */
OnRightTableAdvance(nullptr); OnRightTableAdvance(nullptr);
m_rightClicked = true;
} }
} else if (widget == x174_textpane_body) { } else if (widget == x174_textpane_body) {
m_bodyClicked = true; m_bodyClicked = true;

View File

@ -82,6 +82,8 @@ protected:
bool m_bodyUpClicked : 1; bool m_bodyUpClicked : 1;
bool m_bodyDownClicked : 1; bool m_bodyDownClicked : 1;
bool m_bodyClicked : 1; bool m_bodyClicked : 1;
bool m_leftClicked : 1;
bool m_rightClicked : 1;
bool m_playRightTableSfx : 1; bool m_playRightTableSfx : 1;
}; };
u32 _dummy = 0; u32 _dummy = 0;
@ -117,6 +119,7 @@ public:
virtual void Touch() {} virtual void Touch() {}
virtual void ProcessControllerInput(const CFinalInput& input); virtual void ProcessControllerInput(const CFinalInput& input);
bool ProcessMouseInput(const CFinalInput& input, float yOff); bool ProcessMouseInput(const CFinalInput& input, float yOff);
void ResetMouseState();
virtual void Draw(float transInterp, float totalAlpha, float yOff); virtual void Draw(float transInterp, float totalAlpha, float yOff);
virtual float GetCameraYBias() const { return 0.f; } virtual float GetCameraYBias() const { return 0.f; }
virtual bool VReady() const = 0; virtual bool VReady() const = 0;

View File

@ -44,9 +44,18 @@ void CQuitGameScreen::FinishedLoading() {
.SetText(g_MainStringTable->GetString(23)); .SetText(g_MainStringTable->GetString(23));
x14_tablegroup_quitgame->SetUserSelection(DefaultSelections[int(x0_type)]); x14_tablegroup_quitgame->SetUserSelection(DefaultSelections[int(x0_type)]);
x14_tablegroup_quitgame->SetWorkersMouseActive(true);
x10_loadedFrame->SetMouseUpCallback(std::bind(&CQuitGameScreen::OnWidgetMouseUp, this,
std::placeholders::_1, std::placeholders::_2));
SetColors(); SetColors();
} }
void CQuitGameScreen::OnWidgetMouseUp(CGuiWidget* widget, bool cancel) {
if (!widget || cancel)
return;
DoAdvance(static_cast<CGuiTableGroup*>(widget->GetParent()));
}
void CQuitGameScreen::DoSelectionChange(CGuiTableGroup* caller, int oldSel) { void CQuitGameScreen::DoSelectionChange(CGuiTableGroup* caller, int oldSel) {
SetColors(); SetColors();
CSfxManager::SfxStart(SFXui_quit_change, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(SFXui_quit_change, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
@ -83,6 +92,8 @@ void CQuitGameScreen::ProcessUserInput(const CFinalInput& input) {
return; return;
if (!x10_loadedFrame) if (!x10_loadedFrame)
return; return;
x10_loadedFrame->ProcessMouseInput(input,
CGuiWidgetDrawParms{1.f, zeus::CVector3f{0.f, 0.f, VerticalOffsets[int(x0_type)]}});
x10_loadedFrame->ProcessUserInput(input); x10_loadedFrame->ProcessUserInput(input);
if ((input.PB() || input.PSpecialKey(boo::ESpecialKey::Esc)) && x0_type != EQuitType::ContinueFromLastSave) if ((input.PB() || input.PSpecialKey(boo::ESpecialKey::Esc)) && x0_type != EQuitType::ContinueFromLastSave)
x18_action = EQuitAction::No; x18_action = EQuitAction::No;

View File

@ -9,6 +9,7 @@ struct CFinalInput;
class CGuiFrame; class CGuiFrame;
class CGuiTableGroup; class CGuiTableGroup;
class CGuiTextPane; class CGuiTextPane;
class CGuiWidget;
namespace MP1 { namespace MP1 {
@ -27,6 +28,7 @@ class CQuitGameScreen {
public: public:
void FinishedLoading(); void FinishedLoading();
void OnWidgetMouseUp(CGuiWidget* widget, bool cancel);
void DoSelectionChange(CGuiTableGroup* caller, int oldSel); void DoSelectionChange(CGuiTableGroup* caller, int oldSel);
void DoAdvance(CGuiTableGroup* caller); void DoAdvance(CGuiTableGroup* caller);
EQuitAction Update(float dt); EQuitAction Update(float dt);

View File

@ -102,6 +102,7 @@ public:
void SetPulseGrapple(bool b) { x270_28_pulseGrapple = b; } void SetPulseGrapple(bool b) { x270_28_pulseGrapple = b; }
void SetPulseBeam(bool b) { x270_27_pulseBeam = b; } void SetPulseBeam(bool b) { x270_27_pulseBeam = b; }
float GetViewInterpolation() const { return xc4_viewInterp; } float GetViewInterpolation() const { return xc4_viewInterp; }
bool IsZoomedOut() const { return xc0_userZoom == -4.f; }
}; };
} // namespace MP1 } // namespace MP1

View File

@ -1122,8 +1122,7 @@ void CSamusHud::Update(float dt, const CStateManager& mgr, CInGameGuiManager::EH
break; break;
} }
float aspect = g_Viewport.x8_width / float(g_Viewport.xc_height); float scaleMul = 1.f - zeus::clamp(0.f, (g_Viewport.aspect - 1.33f) / (1.77f - 1.33f), 1.f);
float scaleMul = 1.f - zeus::clamp(0.f, (aspect - 1.33f) / (1.77f - 1.33f), 1.f);
x500_viewportScale.y() = 1.f - scaleMul * morphT * g_tweakGui->GetBallViewportYReduction() * 1.2f; x500_viewportScale.y() = 1.f - scaleMul * morphT * g_tweakGui->GetBallViewportYReduction() * 1.2f;
if (x2b0_ballIntf) if (x2b0_ballIntf)
x2b0_ballIntf->SetBallModeFactor(morphT); x2b0_ballIntf->SetBallModeFactor(morphT);

View File

@ -54,7 +54,7 @@ s32 CFireFlea::sLightIdx = 0;
CFireFlea::CFireFlea(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CFireFlea::CFireFlea(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo, float f1) CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo, float f1)
: CPatterned(ECharacter::FireFlea, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo, : CPatterned(ECharacter::FireFlea, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Flyer, EColliderType::One, EBodyType::NewFlyer, actParms, EKnockBackVariant::Small) EMovementType::Flyer, EColliderType::One, EBodyType::Flyer, actParms, EKnockBackVariant::Small)
, x56c_(f1) , x56c_(f1)
, xd8c_pathFind(nullptr, 2, pInfo.GetPathfindingIndex(), 1.f, 1.f) { , xd8c_pathFind(nullptr, 2, pInfo.GetPathfindingIndex(), 1.f, 1.f) {
CMaterialFilter filter = GetMaterialFilter(); CMaterialFilter filter = GetMaterialFilter();
@ -145,7 +145,7 @@ zeus::CVector3f CFireFlea::FindSafeRoute(CStateManager& mgr, const zeus::CVector
zeus::CVector3f down = -up; zeus::CVector3f down = -up;
CRayCastResult res4 = mgr.RayStaticIntersection(GetTranslation(), down, 1.f, CRayCastResult res4 = mgr.RayStaticIntersection(GetTranslation(), down, 1.f,
CMaterialFilter::MakeInclude({EMaterialTypes::Solid})); CMaterialFilter::MakeInclude({EMaterialTypes::Solid}));
if (res4.IsValid()) { if (res4.IsInvalid()) {
return mag * down; return mag * down;
} else { } else {
return -forward; return -forward;

View File

@ -882,7 +882,7 @@ void CPlayer::TakeDamage(bool significant, const zeus::CVector3f& location, floa
CSfxManager::SfxStop(x770_damageLoopSfx); CSfxManager::SfxStop(x770_damageLoopSfx);
x770_damageLoopSfx.reset(); x770_damageLoopSfx.reset();
} }
x770_damageLoopSfx = CSfxManager::SfxStart(suitDamageSfx, 1.f, 0.f, false, 0x7f, true, kInvalidAreaId); CSfxManager::SfxStart(suitDamageSfx, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
x788_damageLoopSfxId = suitDamageSfx; x788_damageLoopSfxId = suitDamageSfx;
xa2c_damageLoopSfxDelayTicks = 0; xa2c_damageLoopSfxDelayTicks = 0;
doRumble = true; doRumble = true;

View File

@ -138,11 +138,11 @@ CModelFlags CScriptColorModulate::CalculateFlags(const zeus::CColor& col) const
ret.x1_matSetIdx = 0; ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8; ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8;
ret.x4_color = col; ret.x4_color = col;
} else if (x48_blendMode == EBlendMode::Opaque2) { } else if (x48_blendMode == EBlendMode::OpaqueAdd) {
ret.x0_blendMode = 2; ret.x0_blendMode = 2;
ret.x1_matSetIdx = 0; ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8; ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1 | 0x8;
ret.x4_color = col; ret.addColor = col;
} else { } else {
ret.x2_flags = 3; ret.x2_flags = 3;
ret.x4_color = zeus::CColor::skWhite; ret.x4_color = zeus::CColor::skWhite;
@ -182,11 +182,11 @@ CModelFlags CScriptColorModulate::CalculateFlags(const zeus::CColor& col) const
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1; ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
ret.x4_color = col; ret.x4_color = col;
} }
} else if (x48_blendMode == EBlendMode::Opaque2) { } else if (x48_blendMode == EBlendMode::OpaqueAdd) {
ret.x0_blendMode = 2; ret.x0_blendMode = 2;
ret.x1_matSetIdx = 0; ret.x1_matSetIdx = 0;
ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1; ret.x2_flags = x54_26_depthCompare << 0 | x54_27_depthUpdate << 1;
ret.x4_color = col; ret.addColor = col;
} else { } else {
ret.x2_flags = 3; ret.x2_flags = 3;
ret.x4_color = zeus::CColor::skWhite; ret.x4_color = zeus::CColor::skWhite;

View File

@ -12,7 +12,7 @@ public:
Additive, Additive,
Additive2, Additive2,
Opaque, Opaque,
Opaque2, OpaqueAdd,
}; };
enum class EFadeState { A2B, B2A }; enum class EFadeState { A2B, B2A };

View File

@ -262,8 +262,7 @@ void CWorldTransManager::DrawEnabled() {
void CWorldTransManager::DrawDisabled() { m_fadeToBlack.draw(zeus::CColor{0.f, 0.f, 0.f, 0.01f}); } void CWorldTransManager::DrawDisabled() { m_fadeToBlack.draw(zeus::CColor{0.f, 0.f, 0.f, 0.01f}); }
void CWorldTransManager::DrawText() { void CWorldTransManager::DrawText() {
float vpAspectRatio = g_Viewport.x8_width / float(g_Viewport.xc_height); float width = 448.f * g_Viewport.aspect;
float width = 448.f * vpAspectRatio;
CGraphics::SetOrtho(0.f, width, 448.f, 0.f, -4096.f, 4096.f); CGraphics::SetOrtho(0.f, width, 448.f, 0.f, -4096.f, 4096.f);
CGraphics::SetViewPointMatrix(zeus::CTransform::Identity()); CGraphics::SetViewPointMatrix(zeus::CTransform::Identity());
CGraphics::SetModelMatrix(zeus::CTransform::Translate((width - 640.f) / 2.f, 0.f, 448.f)); CGraphics::SetModelMatrix(zeus::CTransform::Translate((width - 640.f) / 2.f, 0.f, 448.f));

View File

@ -210,7 +210,7 @@ static const char* FS =
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n" " float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
" lights[i].angAtt[1] * angDot +\n" " lights[i].angAtt[1] * angDot +\n"
" lights[i].angAtt[0];\n" " lights[i].angAtt[0];\n"
" ret += lights[i].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta).xyz, mvNormIn), 0.0, 1.0);\n" " ret += lights[i].color * angAtt * att * clamp(dot(normalize(-delta).xyz, mvNormIn), 0.0, 1.0);\n"
" }\n" " }\n"
" \n" " \n"
" return ret;\n" " return ret;\n"

View File

@ -246,7 +246,7 @@ static const char* FS =
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n" " float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
" lights[i].angAtt[1] * angDot +\n" " lights[i].angAtt[1] * angDot +\n"
" lights[i].angAtt[0];\n" " lights[i].angAtt[0];\n"
" ret += lights[i].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0);\n" " ret += lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" }\n" " }\n"
" \n" " \n"
" return ret;\n" " return ret;\n"

View File

@ -230,7 +230,7 @@ static const char* FS =
" float angAtt = lu.lights[i].angAtt[2] * angDot * angDot +\n" " float angAtt = lu.lights[i].angAtt[2] * angDot * angDot +\n"
" lu.lights[i].angAtt[1] * angDot +\n" " lu.lights[i].angAtt[1] * angDot +\n"
" lu.lights[i].angAtt[0];\n" " lu.lights[i].angAtt[0];\n"
" ret += lu.lights[i].color * clamp(angAtt, 0.0, 1.0) * att * clamp(dot(normalize(-delta), mvNormIn), 0.0, 1.0);\n" " ret += lu.lights[i].color * angAtt * att * saturate(dot(normalize(-delta), mvNormIn));\n"
" }\n" " }\n"
" \n" " \n"
" return ret;\n" " return ret;\n"

2
amuse

@ -1 +1 @@
Subproject commit 7719459ac700a88e67192379770cf38a2d84e7c0 Subproject commit d80f1346bb7f2b1849e8512d3b2f024c4e428c76