Skip to content

Commit

Permalink
TweakUI: Fix pages, reenable for VR
Browse files Browse the repository at this point in the history
  • Loading branch information
vbousquet committed Mar 16, 2024
1 parent f07316f commit 9bb99ca
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
30 changes: 20 additions & 10 deletions LiveUI.cpp
Expand Up @@ -1117,7 +1117,7 @@ void LiveUI::OpenTweakMode()
m_ShowSplashModal = false;
m_player->DisableStaticPrePass(true);
m_tweakMode = true;
m_activeTweakPage = m_table->m_szRules.empty() ? TP_PointOfView : TP_Rules;
m_activeTweakPage = m_table->m_szRules.empty() ? (m_player->m_stereo3D == STEREO_VR ? TP_TableOption : TP_PointOfView) : TP_Rules;
m_activeTweakIndex = 0;
UpdateTweakPage();
}
Expand Down Expand Up @@ -1240,11 +1240,18 @@ void LiveUI::OnTweakModeEvent(const int keyEvent, const int keycode)
if (keyEvent != 1) // Only keydown
return;
int stepi = up ? 1 : TP_Count - 1;
TweakPage tp = m_activeTweakPage;
m_activeTweakPage = (TweakPage)((m_activeTweakPage + stepi) % TP_Count);
if (m_activeTweakPage == TP_Rules && m_table->m_szRules.empty())
m_activeTweakPage = (TweakPage)((m_activeTweakPage + stepi) % TP_Count);
if (m_activeTweakPage == TP_Info && m_table->m_szDescription.empty())
m_activeTweakPage = (TweakPage)((m_activeTweakPage + stepi) % TP_Count);
while (tp != m_activeTweakPage)
{
tp = m_activeTweakPage;
if (m_activeTweakPage == TP_Info && m_table->m_szDescription.empty())
m_activeTweakPage = (TweakPage)((m_activeTweakPage + stepi) % TP_Count);
if (m_activeTweakPage == TP_Rules && m_table->m_szRules.empty())
m_activeTweakPage = (TweakPage)((m_activeTweakPage + stepi) % TP_Count);
if (m_activeTweakPage == TP_PointOfView && m_player->m_stereo3D == STEREO_VR)
m_activeTweakPage = (TweakPage)((m_activeTweakPage + stepi) % TP_Count);
}
m_activeTweakIndex = 0;
m_tweakScroll = 0.f;
UpdateTweakPage();
Expand Down Expand Up @@ -1677,7 +1684,6 @@ void LiveUI::UpdateTweakModeUI()
ImGui::Text("%s", m_tweakState[id] == 0 ? " " : m_tweakState[id] == 1 ? " **" : " *"); ImGui::TableNextRow(); \
}
#define CM_SKIP_LINE {ImGui::TableNextColumn(); ImGui::Dummy(ImVec2(0.f, m_dpi * 3.f)); ImGui::TableNextRow();}
const int nTweakPages = 2 + (m_table->m_szRules.empty() ? 0 : 1) + (m_table->m_szDescription.empty() ? 0 : 1);
const float realToVirtual = viewSetup.GetRealToVirtualScale(table);
for (int setting : m_tweakPageOptions)
{
Expand Down Expand Up @@ -1710,17 +1716,21 @@ void LiveUI::UpdateTweakModeUI()
}
else switch (setting)
{
case BS_Page:
CM_ROW(setting,
"Page "s.append(std::to_string(m_activeTweakPage + 1 - (m_table->m_szRules.empty() ? 1 : 0) - (m_table->m_szDescription.empty() ? 1 : 0)))
.append("/").append(std::to_string(nTweakPages)).c_str(),"%s",
case BS_Page: {
const int pageIndex = m_activeTweakPage
- ((m_activeTweakPage > TP_Info && m_table->m_szDescription.empty()) ? 1 : 0)
- ((m_activeTweakPage > TP_Rules && m_table->m_szRules.empty()) ? 1 : 0)
- ((m_activeTweakPage > TP_PointOfView && m_player->m_stereo3D == STEREO_VR) ? 1 : 0);
const int nTweakPages = 1 + (m_table->m_szRules.empty() ? 0 : 1) + (m_table->m_szDescription.empty() ? 0 : 1) + (m_player->m_stereo3D == STEREO_VR ? 0 : 1);
CM_ROW(setting, "Page "s.append(std::to_string(1 + pageIndex)).append("/").append(std::to_string(nTweakPages)).c_str(), "%s",
m_activeTweakPage == TP_TableOption ? "Table Options"
: m_activeTweakPage == TP_PointOfView ? "Point of View"
: m_activeTweakPage == TP_Rules ? "Rules"
: "Information",
"");
CM_SKIP_LINE;
break;
}

// View setup
case BS_ViewMode: CM_ROW(setting, "View Layout Mode:", "%s", isLegacy ? "Legacy" : isCamera ? "Camera" : "Window", ""); CM_SKIP_LINE; break;
Expand Down
2 changes: 1 addition & 1 deletion pininput.cpp
Expand Up @@ -1969,7 +1969,7 @@ void PinInput::ProcessKeys(/*const U32 curr_sim_msec,*/ int curr_time_msec) // l
if ((input->dwData & 0x80) != 0)
g_pplayer->m_liveUI->PausePlayer(!g_pplayer->m_debugWindowActive);
}
else if (input->dwOfs == (DWORD)g_pplayer->m_rgKeys[eTweak] && g_pplayer->m_stereo3D != STEREO_VR)
else if (input->dwOfs == (DWORD)g_pplayer->m_rgKeys[eTweak])
{
if ((input->dwData & 0x80) != 0)
{
Expand Down
10 changes: 5 additions & 5 deletions src/core/player.cpp
Expand Up @@ -1766,7 +1766,7 @@ HRESULT Player::Init()
m_liveUI->PushNotification("You can use Touch controls on this display: bottom left area to Start Game, bottom right area to use the Plunger\n"
"lower left/right for Flippers, upper left/right for Magna buttons, top left for Credits and (hold) top right to Exit"s, 12000);

if (m_playMode == 1 && m_stereo3D != STEREO_VR)
if (m_playMode == 1)
m_liveUI->OpenTweakMode();
else if (m_playMode == 2 && m_stereo3D != STEREO_VR)
m_liveUI->OpenLiveUI();
Expand Down Expand Up @@ -3636,14 +3636,14 @@ void Player::PrepareVideoBuffers()
m_pin3d.m_pd3dPrimaryDevice->SetRenderTarget("Left Eye"s, leftTexture, false);
m_pin3d.m_pd3dPrimaryDevice->AddRenderTargetDependency(renderedRT);
m_pin3d.m_pd3dPrimaryDevice->BlitRenderTarget(renderedRT, leftTexture, true, false, 0, 0, w, h, 0, 0, w, h, 0, 0);
if (m_liveUI->IsTweakMode())
if (m_liveUI->IsTweakMode()) // Render as an overlay in VR (not in preview) at the eye resolution, without depth
m_pin3d.m_pd3dPrimaryDevice->RenderLiveUI();

RenderTarget *rightTexture = m_pin3d.m_pd3dPrimaryDevice->GetOffscreenVR(1);
m_pin3d.m_pd3dPrimaryDevice->SetRenderTarget("Right Eye"s, rightTexture, false);
m_pin3d.m_pd3dPrimaryDevice->AddRenderTargetDependency(renderedRT);
m_pin3d.m_pd3dPrimaryDevice->BlitRenderTarget(renderedRT, rightTexture, true, false, 0, 0, w, h, 0, 0, w, h, 1, 0);
if (m_liveUI->IsTweakMode())
if (m_liveUI->IsTweakMode()) // Render as an overlay in VR (not in preview) at the eye resolution, without depth
m_pin3d.m_pd3dPrimaryDevice->RenderLiveUI();

RenderTarget *outRT = m_pin3d.m_pd3dPrimaryDevice->GetOutputBackBuffer();
Expand Down Expand Up @@ -3725,7 +3725,7 @@ void Player::PrepareVideoBuffers()
renderedRT = outputRT;
}

if (!stereo || m_stereo3D != STEREO_VR)
if (m_stereo3D != STEREO_VR)
{
// Except for VR, render LiveUI after tonemapping and stereo (otherwise it would break the calibration process for stereo anaglyph)
g_frameProfiler.EnterProfileSection(FrameProfiler::PROFILE_MISC);
Expand Down Expand Up @@ -4088,7 +4088,7 @@ void Player::SubmitFrame()
// Submit to GPU render queue
g_frameProfiler.EnterProfileSection(FrameProfiler::PROFILE_GPU_SUBMIT);
m_pin3d.m_pd3dPrimaryDevice->FlushRenderFrame();
if (m_stereo3D == STEREO_VR && m_vrPreview != VRPREVIEW_DISABLED && !m_liveUI->IsTweakMode())
if (m_stereo3D == STEREO_VR && m_vrPreview != VRPREVIEW_DISABLED && !m_liveUI->IsTweakMode() && m_liveUI->IsOpened())
{
m_pin3d.m_pd3dPrimaryDevice->SetRenderTarget("ImgUI-Preview"s, m_pin3d.m_pd3dPrimaryDevice->GetOutputBackBuffer(), false);
m_liveUI->Update(m_pin3d.m_pd3dPrimaryDevice->GetOutputBackBuffer());
Expand Down

0 comments on commit 9bb99ca

Please sign in to comment.