Skip to content

Commit

Permalink
T-Panel: Fixed fullsize-helptex being cut off
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Oct 27, 2024
1 parent 465a105 commit 0450b2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
26 changes: 24 additions & 2 deletions source/main/gui/panels/GUI_VehicleInfoTPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,15 @@ void VehicleInfoTPanel::DrawVehicleCommandsUI(RoR::GfxActor* actorx)
ImGui::SetCursorPosX(MIN_PANEL_WIDTH - (ImGui::CalcTextSize(_LC("VehicleDescription", "Full size")).x + 25.f));
ImGui::Checkbox(_LC("VehicleDescription", "Full size"), &m_helptext_fullsize);

ImTextureID im_tex = reinterpret_cast<ImTextureID>(actorx->GetHelpTex()->getHandle());
if (m_helptext_fullsize)
{
ImGui::Image(im_tex, ImVec2(HELP_TEXTURE_WIDTH, HELP_TEXTURE_HEIGHT));
m_helptext_fullsize_screenpos = ImGui::GetCursorScreenPos();
ImGui::Dummy(ImVec2(MIN_PANEL_WIDTH, HELP_TEXTURE_HEIGHT));
this->DrawVehicleHelpTextureFullsize(actorx);
}
else
{
ImTextureID im_tex = reinterpret_cast<ImTextureID>(actorx->GetHelpTex()->getHandle());
ImGui::Image(im_tex, ImVec2(MIN_PANEL_WIDTH, HELP_TEXTURE_HEIGHT));
}
}
Expand Down Expand Up @@ -802,6 +804,26 @@ void VehicleInfoTPanel::DrawVehicleCommandHighlights(RoR::GfxActor* actorx)
}
}

void VehicleInfoTPanel::DrawVehicleHelpTextureFullsize(RoR::GfxActor* actorx)
{
// In order to draw the image on top of the T-panel, the window must be focusable,
// so we can't simply use `GetImDummyFullscreenWindow()`
// ===============================================================================

int window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar
| ImGuiWindowFlags_NoSavedSettings ;
ImGui::SetNextWindowPos(m_helptext_fullsize_screenpos - ImGui::GetStyle().WindowPadding);
ImGui::SetNextWindowSize(ImVec2(HELP_TEXTURE_WIDTH, HELP_TEXTURE_HEIGHT) + ImGui::GetStyle().WindowPadding);
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); // Fully transparent background!
ImGui::Begin("T-Panel help tex fullsize", NULL, window_flags);
ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImTextureID im_tex = reinterpret_cast<ImTextureID>(actorx->GetHelpTex()->getHandle());
drawlist->AddImage(im_tex, m_helptext_fullsize_screenpos,
m_helptext_fullsize_screenpos + ImVec2(HELP_TEXTURE_WIDTH, HELP_TEXTURE_HEIGHT));
ImGui::End();
ImGui::PopStyleColor(1); // WindowBg
}

bool DrawSingleButtonRow(bool active, const Ogre::TexturePtr& icon, const char* name, RoR::events ev, bool* btn_active = nullptr)
{
if (active)
Expand Down
2 changes: 2 additions & 0 deletions source/main/gui/panels/GUI_VehicleInfoTPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class VehicleInfoTPanel
/// @{
void DrawVehicleCommandsUI(RoR::GfxActor* actorx);
void DrawVehicleCommandHighlights(RoR::GfxActor* actorx);
void DrawVehicleHelpTextureFullsize(RoR::GfxActor* actorx);

CommandkeyID_t m_active_commandkey = COMMANDKEYID_INVALID;
CommandkeyID_t m_hovered_commandkey = COMMANDKEYID_INVALID;
Expand All @@ -70,6 +71,7 @@ class VehicleInfoTPanel
float m_cmdbeam_highlight_thickness = 15.f;
ImVec4 m_command_hovered_text_color = ImVec4(0.1f, 0.1f, 0.1f, 1.f);
bool m_helptext_fullsize = false;
ImVec2 m_helptext_fullsize_screenpos; //!< The image is drawn into separate window
/// @}

/// @name 'Vehicle stats' tab
Expand Down

0 comments on commit 0450b2f

Please sign in to comment.