Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restored mirroring of texture feature for CUIStatic #1690

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/xrUICore/Static/UIStaticItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ void CUIStaticItem::RenderInternal(const Fvector2& in_pos)
LTt.set(TextureRect.x1 / ts.x, TextureRect.y1 / ts.y);
RBt.set(TextureRect.x2 / ts.x, TextureRect.y2 / ts.y);

// Check mirror mode
if (EUIMirroring::Horisontal == eMirrorMode || EUIMirroring::Both == eMirrorMode)
std::swap(LTt.x, RBt.x);
if (EUIMirroring::Vertical == eMirrorMode || EUIMirroring::Both == eMirrorMode)
std::swap(LTt.y, RBt.y);

float offset = -0.5f;
if (UI().m_currentPointType == IUIRender::pttLIT)
offset = 0.0f;
Expand Down Expand Up @@ -131,6 +137,12 @@ void CUIStaticItem::RenderInternal(float angle)
LTt.set(TextureRect.x1 / ts.x + hp.x, TextureRect.y1 / ts.y + hp.y);
RBt.set(TextureRect.x2 / ts.x + hp.x, TextureRect.y2 / ts.y + hp.y);

// Check mirror mode
if (EUIMirroring::Horisontal == eMirrorMode || EUIMirroring::Both == eMirrorMode)
std::swap(LTt.x, RBt.x);
if (EUIMirroring::Vertical == eMirrorMode || EUIMirroring::Both == eMirrorMode)
std::swap(LTt.y, RBt.y);

float kx = UI().get_current_kx();

// clip poly
Expand Down
12 changes: 12 additions & 0 deletions src/xrUICore/Static/UIStaticItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
#include "xrCore/xrstring.h"
#endif

enum class EUIMirroring
{
None,
Horisontal,
Vertical,
Both
};

class XRUICORE_API CUIStaticItem
{
protected:
Expand All @@ -22,6 +30,7 @@ class XRUICORE_API CUIStaticItem
Fvector2 vHeadingPivot;
Fvector2 vHeadingOffset;
Flags8 uFlags;
EUIMirroring eMirrorMode{};

ui_shader hShader;
Fvector2 vPos;
Expand Down Expand Up @@ -65,6 +74,9 @@ class XRUICORE_API CUIStaticItem
void ResetHeadingPivot();
IC bool GetFixedLTWhileHeading() const { return !!uFlags.test(flFixedLTWhileHeading); }
Fvector2 GetHeadingPivot() { return vHeadingPivot; }
IC void SetMirrorMode(EUIMirroring m) { eMirrorMode = m; }
IC EUIMirroring GetMirrorMode() { return eMirrorMode; }

private:
void RenderInternal(const Fvector2& pos);
void RenderInternal(float angle);
Expand Down
8 changes: 8 additions & 0 deletions src/xrUICore/XML/UIXmlInitBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ bool CUIXmlInitBase::InitStatic(CUIXml& xml_doc, pcstr path, int index, CUIStati
InitTexture(xml_doc, path, index, pWnd);
InitTextureOffset(xml_doc, path, index, pWnd);

cpcstr mirroring = xml_doc.ReadAttrib(path, index, "mirror", "");
if (0 == xr_strcmp(mirroring, "h"))
pWnd->GetStaticItem()->SetMirrorMode(EUIMirroring::Horisontal);
else if (0 == xr_strcmp(mirroring, "v"))
pWnd->GetStaticItem()->SetMirrorMode(EUIMirroring::Vertical);
else if (0 == xr_strcmp(mirroring, "b"))
pWnd->GetStaticItem()->SetMirrorMode(EUIMirroring::Both);

const int flag = xml_doc.ReadAttribInt(path, index, "heading", 0);
pWnd->EnableHeading((flag) ? true : false);

Expand Down
Loading