Skip to content

Commit 2a756ce

Browse files
committed
T-Panel: Fixed fullsize-helptex being cut off
1 parent 307804e commit 2a756ce

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

source/main/gui/panels/GUI_VehicleInfoTPanel.cpp

+24-2
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,15 @@ void VehicleInfoTPanel::DrawVehicleCommandsUI(RoR::GfxActor* actorx)
220220
ImGui::SetCursorPosX(MIN_PANEL_WIDTH - (ImGui::CalcTextSize(_LC("VehicleDescription", "Full size")).x + 25.f));
221221
ImGui::Checkbox(_LC("VehicleDescription", "Full size"), &m_helptext_fullsize);
222222

223-
ImTextureID im_tex = reinterpret_cast<ImTextureID>(actorx->GetHelpTex()->getHandle());
224223
if (m_helptext_fullsize)
225224
{
226-
ImGui::Image(im_tex, ImVec2(HELP_TEXTURE_WIDTH, HELP_TEXTURE_HEIGHT));
225+
m_helptext_fullsize_screenpos = ImGui::GetCursorScreenPos();
226+
ImGui::Dummy(ImVec2(MIN_PANEL_WIDTH, HELP_TEXTURE_HEIGHT));
227+
this->DrawVehicleHelpTextureFullsize(actorx);
227228
}
228229
else
229230
{
231+
ImTextureID im_tex = reinterpret_cast<ImTextureID>(actorx->GetHelpTex()->getHandle());
230232
ImGui::Image(im_tex, ImVec2(MIN_PANEL_WIDTH, HELP_TEXTURE_HEIGHT));
231233
}
232234
}
@@ -802,6 +804,26 @@ void VehicleInfoTPanel::DrawVehicleCommandHighlights(RoR::GfxActor* actorx)
802804
}
803805
}
804806

807+
void VehicleInfoTPanel::DrawVehicleHelpTextureFullsize(RoR::GfxActor* actorx)
808+
{
809+
// In order to draw the image on top of the T-panel, the window must be focusable,
810+
// so we can't simply use `GetImDummyFullscreenWindow()`
811+
// ===============================================================================
812+
813+
int window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar
814+
| ImGuiWindowFlags_NoSavedSettings ;
815+
ImGui::SetNextWindowPos(m_helptext_fullsize_screenpos - ImGui::GetStyle().WindowPadding);
816+
ImGui::SetNextWindowSize(ImVec2(HELP_TEXTURE_WIDTH, HELP_TEXTURE_HEIGHT) + ImGui::GetStyle().WindowPadding);
817+
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0)); // Fully transparent background!
818+
ImGui::Begin("T-Panel help tex fullsize", NULL, window_flags);
819+
ImDrawList* drawlist = ImGui::GetWindowDrawList();
820+
ImTextureID im_tex = reinterpret_cast<ImTextureID>(actorx->GetHelpTex()->getHandle());
821+
drawlist->AddImage(im_tex, m_helptext_fullsize_screenpos,
822+
m_helptext_fullsize_screenpos + ImVec2(HELP_TEXTURE_WIDTH, HELP_TEXTURE_HEIGHT));
823+
ImGui::End();
824+
ImGui::PopStyleColor(1); // WindowBg
825+
}
826+
805827
bool DrawSingleButtonRow(bool active, const Ogre::TexturePtr& icon, const char* name, RoR::events ev, bool* btn_active = nullptr)
806828
{
807829
if (active)

source/main/gui/panels/GUI_VehicleInfoTPanel.h

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class VehicleInfoTPanel
6161
/// @{
6262
void DrawVehicleCommandsUI(RoR::GfxActor* actorx);
6363
void DrawVehicleCommandHighlights(RoR::GfxActor* actorx);
64+
void DrawVehicleHelpTextureFullsize(RoR::GfxActor* actorx);
6465

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

7577
/// @name 'Vehicle stats' tab

0 commit comments

Comments
 (0)