Skip to content

Commit

Permalink
Merge pull request #26 from Jacob-Mango/feature/ghosticons
Browse files Browse the repository at this point in the history
feature/ghosticons
  • Loading branch information
Jacob-Mango committed Dec 3, 2020
2 parents 5621666 + 0945f1d commit a5a15de
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
2 changes: 2 additions & 0 deletions JM/CF/Defines/CFDefines.c
Expand Up @@ -2,6 +2,8 @@
#define CF_MODULE_CONFIG
//#define CF_MODULE_PERMISSIONS

#define CF_GHOSTICONS_V2

#ifdef CF_MODULE_LAYOUT_BINDING
#define CF_MODEL_VIEW_BINDING
#endif
@@ -0,0 +1,35 @@
modded class AttachmentCategoriesContainer
{
override void LoadAttachmentCategoriesIcon(SlotsContainer items_cont, string icon_name, int slot_number)
{
SlotsIcon icon = items_cont.GetSlotIcon(slot_number);
ImageWidget image_widget = icon.GetGhostSlot();
image_widget.Show(true);

string path = "CfgSlots" + " Slot_" + InventorySlots.GetSlotName(icon.GetSlotID());

if ( GetGame().ConfigIsExisting( path + " modGhostIcon" ) && GetGame().ConfigGetText( path + " modGhostIcon", icon_name ) && icon_name != "" )
{
image_widget.LoadImageFile(0, icon_name);

if (m_Body.Count() > (slot_number + 2))
{
ClosableContainer c = ClosableContainer.Cast(m_Body.Get(slot_number + 2));
icon.GetRadialIconPanel().Show(true);
if (c && c.IsOpened())
{
icon.GetRadialIconClosed().Show(false);
icon.GetRadialIcon().Show(true);
}
else
{
icon.GetRadialIcon().Show(false);
icon.GetRadialIconClosed().Show(true);
}
}
} else
{
super.LoadAttachmentCategoriesIcon(items_cont, icon_name, slot_number);
}
}
};
@@ -0,0 +1,38 @@
modded class Attachments
{
override void InitAttachmentGrid(int att_row_index)
{
super.InitAttachmentGrid(att_row_index);

for (int i = 0; i < m_AttachmentSlotNames.Count(); i++)
{
SlotsIcon icon2 = SlotsContainer.Cast(m_AttachmentsContainer.Get((i / ITEMS_IN_ROW))).GetSlotIcon(i % ITEMS_IN_ROW);
WidgetEventHandler.GetInstance().RegisterOnDoubleClick(icon2.GetPanelWidget(), m_Parent, "DoubleClick");

string path = "CfgSlots" + " Slot_" + m_AttachmentSlotNames[i];

//Show different magazine icon for firearms and pistols
if (m_AttachmentSlotNames[i] == "magazine")
{
if (!m_Entity.IsInherited(Pistol_Base))
path = "CfgSlots" + " Slot_" + "magazine2";
}

string icon_name = "";
if (GetGame().ConfigIsExisting(path + " modGhostIcon") && GetGame().ConfigGetText(path + " modGhostIcon", icon_name) && icon_name != "")
{
icon2.GetGhostSlot().LoadImageFile(0, icon_name);

int slot_id = InventorySlots.GetSlotIdFromString(m_AttachmentSlotNames[i]);
m_AttachmentSlots.Insert(slot_id, icon2);
icon2.SetSlotID(slot_id);

EntityAI item = m_Entity.GetInventory().FindAttachment(slot_id);
if (item)
AttachmentAdded(item, m_AttachmentSlotNames[i], m_Entity);
else
icon2.Clear();
}
}
}
};

0 comments on commit a5a15de

Please sign in to comment.