Skip to content

Commit

Permalink
SWM: Fixed wrong addon icon position for a weapon in slot, drag and d…
Browse files Browse the repository at this point in the history
…rop included (16:9)
  • Loading branch information
ShokerStlk committed Jan 2, 2019
1 parent f8ffaa6 commit 743a4ec
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 27 deletions.
12 changes: 6 additions & 6 deletions res/gamedata/configs/ui/actor_menu_16.xml
Expand Up @@ -217,15 +217,15 @@
custom_placement="0" a="0" virtual_cells="1" vc_vert_align="c"
vc_horiz_align="c"/>

<dragdrop_pistol x="384" y="14" width="74" height="305"
cell_width="33" cell_height="41" rows_num="6" cols_num="2"
<dragdrop_pistol x="384" y="14" width="90" height="305"
cell_width="41" cell_height="41" rows_num="6" cols_num="2"
custom_placement="0" vertical_placement="1" a="0"
virtual_cells="1" vc_vert_align="c" vc_horiz_align="c"/>
virtual_cells="1" vc_vert_align="c" vc_horiz_align="c"/> <!--#SM+#-->

<dragdrop_automatic x="563" y="14" width="74" height="305"
cell_width="33" cell_height="41" rows_num="6" cols_num="2"
<dragdrop_automatic x="563" y="14" width="90" height="305"
cell_width="41" cell_height="41" rows_num="6" cols_num="2"
custom_placement="0" vertical_placement="1" a="0"
virtual_cells="1" vc_vert_align="c" vc_horiz_align="c" />
virtual_cells="1" vc_vert_align="c" vc_horiz_align="c" /> <!--#SM+#-->

<dragdrop_actor_trade x="662" y="114" width="250" height="164"
cell_width="33" cell_height="41" rows_num="4" cols_num="7"
Expand Down
35 changes: 21 additions & 14 deletions src/xrGame/ui/UICellCustomItems.cpp
Expand Up @@ -60,9 +60,9 @@ bool CUIInventoryCellItem::IsHelperOrHasHelperChild()
return std::count_if(m_childs.begin(), m_childs.end(), detail::is_helper_pred()) > 0 || IsHelper();
}

CUIDragItem* CUIInventoryCellItem::CreateDragItem()
CUIDragItem* CUIInventoryCellItem::CreateDragItem(bool bRotate) //--#SM+#--
{
return IsHelperOrHasHelperChild() ? NULL : inherited::CreateDragItem();
return IsHelperOrHasHelperChild() ? NULL : inherited::CreateDragItem(bRotate);
}

bool CUIInventoryCellItem::IsHelper() { return object()->is_helper_item(); }
Expand Down Expand Up @@ -122,7 +122,7 @@ bool CUIAmmoCellItem::EqualTo(CUICellItem* itm)
return ((object()->cNameSect() == ci->object()->cNameSect()));
}

CUIDragItem* CUIAmmoCellItem::CreateDragItem() { return IsHelper() ? NULL : inherited::CreateDragItem(); }
CUIDragItem* CUIAmmoCellItem::CreateDragItem(bool bRotate) { return IsHelper() ? NULL : inherited::CreateDragItem(bRotate); } //--#SM+#--
u32 CUIAmmoCellItem::CalculateAmmoCount()
{
xr_vector<CUICellItem*>::iterator it = m_childs.begin();
Expand Down Expand Up @@ -565,25 +565,32 @@ void CUIWeaponCellItem::InitAddon(CUIStatic* s, LPCSTR section, Fvector2 addon_o
s->EnableHeading(b_rotate);

if (b_rotate)
{ //SM_TODO: Починить растяжку текстуры \ аддонов по вертикали
{
s->SetHeading(GetHeading());
Fvector2 offs;
offs.set(0.0f, s->GetWndSize().y);
s->SetHeadingPivot(Fvector2().set(0.0f, 0.0f), /*Fvector2().set(0.0f,0.0f)*/ offs, true);
}
}

CUIDragItem* CUIWeaponCellItem::CreateDragItem()
CUIDragItem* CUIWeaponCellItem::CreateDragItem(bool bRotate) //--#SM+#--
{
CUIDragItem* i = inherited::CreateDragItem();
CUIDragItem* i = inherited::CreateDragItem(bRotate); //--#SM+#--
CUIStatic* s = NULL;

if (bRotate) //--#SM+#--
{
i->wnd()->EnableHeading(true);
i->wnd()->SetHeading(90.0f * (PI / 180.0f));
i->wnd()->SetHeadingPivot(Fvector2().set(0.0f, 0.0f), Fvector2().set(0.0f, i->wnd()->GetWndSize().y), true);
}

if (GetIcon(eSilencer))
{
s = new CUIStatic();
s->SetAutoDelete(true);
s->SetShader(InventoryUtilities::GetEquipmentIconsShader());
InitAddon(s, *object()->GetSilencerName(), m_addon_offset[eSilencer], false);
InitAddon(s, *object()->GetSilencerName(), m_addon_offset[eSilencer], bRotate); //--#SM+#--
s->SetTextureColor(i->wnd()->GetTextureColor());
i->wnd()->AttachChild(s);
}
Expand All @@ -593,7 +600,7 @@ CUIDragItem* CUIWeaponCellItem::CreateDragItem()
s = new CUIStatic();
s->SetAutoDelete(true);
s->SetShader(InventoryUtilities::GetEquipmentIconsShader());
InitAddon(s, *object()->GetScopeName(), m_addon_offset[eScope], false);
InitAddon(s, *object()->GetScopeName(), m_addon_offset[eScope], bRotate); //--#SM+#--
s->SetTextureColor(i->wnd()->GetTextureColor());
i->wnd()->AttachChild(s);
}
Expand All @@ -603,7 +610,7 @@ CUIDragItem* CUIWeaponCellItem::CreateDragItem()
s = new CUIStatic();
s->SetAutoDelete(true);
s->SetShader(InventoryUtilities::GetEquipmentIconsShader());
InitAddon(s, *object()->GetGrenadeLauncherName(), m_addon_offset[eLauncher], false);
InitAddon(s, *object()->GetGrenadeLauncherName(), m_addon_offset[eLauncher], bRotate); //--#SM+#--
s->SetTextureColor(i->wnd()->GetTextureColor());
i->wnd()->AttachChild(s);
}
Expand All @@ -613,7 +620,7 @@ CUIDragItem* CUIWeaponCellItem::CreateDragItem()
s = new CUIStatic();
s->SetAutoDelete(true);
s->SetShader(InventoryUtilities::GetEquipmentIconsShader());
InitAddon(s, *object()->GetMagazineName(), m_addon_offset[eMagazine], false);
InitAddon(s, *object()->GetMagazineName(), m_addon_offset[eMagazine], bRotate);
s->SetTextureColor(i->wnd()->GetTextureColor());
i->wnd()->AttachChild(s);
}
Expand All @@ -623,7 +630,7 @@ CUIDragItem* CUIWeaponCellItem::CreateDragItem()
s = new CUIStatic();
s->SetAutoDelete(true);
s->SetShader(InventoryUtilities::GetEquipmentIconsShader());
InitAddon(s, *object()->GetSpecial_1_Name(), m_addon_offset[eSpecial_1], false);
InitAddon(s, *object()->GetSpecial_1_Name(), m_addon_offset[eSpecial_1], bRotate);
s->SetTextureColor(i->wnd()->GetTextureColor());
i->wnd()->AttachChild(s);
}
Expand All @@ -633,7 +640,7 @@ CUIDragItem* CUIWeaponCellItem::CreateDragItem()
s = new CUIStatic();
s->SetAutoDelete(true);
s->SetShader(InventoryUtilities::GetEquipmentIconsShader());
InitAddon(s, *object()->GetSpecial_2_Name(), m_addon_offset[eSpecial_2], false);
InitAddon(s, *object()->GetSpecial_2_Name(), m_addon_offset[eSpecial_2], bRotate);
s->SetTextureColor(i->wnd()->GetTextureColor());
i->wnd()->AttachChild(s);
}
Expand All @@ -643,7 +650,7 @@ CUIDragItem* CUIWeaponCellItem::CreateDragItem()
s = new CUIStatic();
s->SetAutoDelete(true);
s->SetShader(InventoryUtilities::GetEquipmentIconsShader());
InitAddon(s, *object()->GetSpecial_3_Name(), m_addon_offset[eSpecial_3], false);
InitAddon(s, *object()->GetSpecial_3_Name(), m_addon_offset[eSpecial_3], bRotate);
s->SetTextureColor(i->wnd()->GetTextureColor());
i->wnd()->AttachChild(s);
}
Expand All @@ -653,7 +660,7 @@ CUIDragItem* CUIWeaponCellItem::CreateDragItem()
s = new CUIStatic();
s->SetAutoDelete(true);
s->SetShader(InventoryUtilities::GetEquipmentIconsShader());
InitAddon(s, *object()->GetSpecial_4_Name(), m_addon_offset[eSpecial_4], false);
InitAddon(s, *object()->GetSpecial_4_Name(), m_addon_offset[eSpecial_4], bRotate);
s->SetTextureColor(i->wnd()->GetTextureColor());
i->wnd()->AttachChild(s);
}
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/ui/UICellCustomItems.h
Expand Up @@ -10,7 +10,7 @@ class CUIInventoryCellItem : public CUICellItem
CUIInventoryCellItem(CInventoryItem* itm);
virtual bool EqualTo(CUICellItem* itm);
virtual void UpdateItemText();
CUIDragItem* CreateDragItem();
virtual CUIDragItem* CreateDragItem(bool bRotate = false); //--#SM+#--
virtual bool IsHelper();
virtual void SetIsHelper(bool is_helper);
bool IsHelperOrHasHelperChild();
Expand All @@ -30,7 +30,7 @@ class CUIAmmoCellItem : public CUIInventoryCellItem

u32 CalculateAmmoCount();
virtual bool EqualTo(CUICellItem* itm);
virtual CUIDragItem* CreateDragItem();
virtual CUIDragItem* CreateDragItem(bool bRotate = false); //--#SM+#--
CWeaponAmmo* object() { return (CWeaponAmmo*)m_pData; }
};

Expand Down Expand Up @@ -80,7 +80,7 @@ class CUIWeaponCellItem : public CUIInventoryCellItem

CWeapon* object() { return (CWeapon*)m_pData; }
virtual void OnAfterChild(CUIDragDropListEx* parent_list);
virtual CUIDragItem* CreateDragItem();
virtual CUIDragItem* CreateDragItem(bool bRotate = false); //--#SM+#--
virtual bool EqualTo(CUICellItem* itm);
CUIStatic* get_addon_static(u32 idx) { return m_addons[idx]; }
};
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ui/UICellItem.cpp
Expand Up @@ -178,14 +178,14 @@ bool CUICellItem::OnKeyboardAction(int dik, EUIMessages keyboard_action)
return inherited::OnKeyboardAction(dik, keyboard_action);
}

CUIDragItem* CUICellItem::CreateDragItem()
CUIDragItem* CUICellItem::CreateDragItem(bool bRotate) //--#SM+#--
{
CUIDragItem* tmp;
tmp = new CUIDragItem(this);
Frect r;
GetAbsoluteRect(r);

if (m_UIStaticItem.GetFixedLTWhileHeading())
if (bRotate == false && m_UIStaticItem.GetFixedLTWhileHeading()) //--#SM+#--
{
float t1, t2;
t1 = r.width();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ui/UICellItem.h
Expand Up @@ -62,7 +62,7 @@ class CUICellItem : public CUIStatic
IC const Ivector2& GetGridSize() { return m_grid_size; }; // size in grid
IC void SetAccelerator(int dik) { m_accelerator = dik; };
IC int GetAccelerator() const { return m_accelerator; };
virtual CUIDragItem* CreateDragItem();
virtual CUIDragItem* CreateDragItem(bool bRotate = false); //--#SM+#--

CUIDragDropListEx* OwnerList() { return m_pParentList; }
void SetOwnerList(CUIDragDropListEx* p);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ui/UIDragDropListEx.cpp
Expand Up @@ -98,7 +98,7 @@ void CUIDragDropListEx::OnScrollV(CUIWindow* w, void* pData)
void CUIDragDropListEx::CreateDragItem(CUICellItem* itm)
{
R_ASSERT(!m_drag_item);
m_drag_item = itm->CreateDragItem();
m_drag_item = itm->CreateDragItem(GetVerticalPlacement()); //--#SM+#--

if (m_drag_item)
{
Expand Down

0 comments on commit 743a4ec

Please sign in to comment.