File size: 2,200 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
class ModsMenuSimpleEntry extends ScriptedWidgetEventHandler
{
protected ButtonWidget m_ModButton;
protected ImageWidget m_Icon;
protected Widget m_Hover;
protected bool m_HasLogoOver;
protected ModInfo m_Data;
protected ModsMenuSimple m_ParentMenu;
void ModsMenuSimpleEntry(ModInfo data, int index, Widget parent, ModsMenuSimple parent_menu)
{
m_ModButton = ButtonWidget.Cast(GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/mods_menu/mods_menu_simple_entry.layout", parent));
m_Icon = ImageWidget.Cast(m_ModButton.FindAnyWidget("Icon"));
m_Hover = m_ModButton.FindAnyWidget("Overlay");
m_Data = data;
m_ParentMenu = parent_menu;
m_ModButton.SetSort(index);
m_ModButton.SetHandler(this);
LoadData();
}
void ~ModsMenuSimpleEntry()
{
delete m_ModButton;
}
void LoadData()
{
string logo = m_Data.GetLogo();
string logo_over = m_Data.GetLogoOver();
if (logo != "")
{
m_Icon.LoadImageFile(0, logo);
}
else
{
m_Icon.LoadImageFile(0, ModInfo.DEFAULT_LOGO);
}
if (logo_over != "")
{
m_Icon.LoadImageFile(1, logo_over);
}
else
{
m_Icon.LoadImageFile(1, ModInfo.DEFAULT_LOGO_OVER);
}
m_HasLogoOver = true;
}
override bool OnClick(Widget w, int x, int y, int button)
{
if( w == m_ModButton )
{
m_ParentMenu.Select( m_Data );
return true;
}
return false;
}
override bool OnMouseEnter(Widget w, int x, int y)
{
if( w == m_ModButton )
{
if( m_HasLogoOver )
m_Icon.SetImage( 1 );
m_Hover.Show( true );
return true;
}
return false;
}
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
{
if( enterW != m_ModButton )
{
if( m_HasLogoOver )
m_Icon.SetImage( 0 );
m_Hover.Show( false );
return true;
}
return false;
}
override bool OnFocus( Widget w, int x, int y )
{
if( w == m_ModButton )
{
if( m_HasLogoOver )
m_Icon.SetImage( 1 );
m_Hover.Show( true );
return true;
}
return false;
}
override bool OnFocusLost( Widget w, int x, int y )
{
if( w == m_ModButton )
{
if( m_HasLogoOver )
m_Icon.SetImage( 0 );
m_Hover.Show( false );
return true;
}
return false;
}
} |