123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- class ModsMenuDetailedEntry extends ScriptedWidgetEventHandler
- {
- protected Widget m_Root;
- protected Widget m_Detail;
-
- //Header
- protected ImageWidget m_IconSmall;
- protected ImageWidget m_IconCollapse;
- protected TextWidget m_Name;
-
- //Left Side Panel
- protected ImageWidget m_IconBig;
- protected MultilineTextWidget m_Author;
- protected TextWidget m_Version;
- protected RichTextWidget m_ActionWebsite;
- protected RichTextWidget m_ActionPurchase;
-
- //Description Panel
- protected RichTextWidget m_Description;
- protected ModInfo m_Data;
- protected ModsMenuDetailed m_ParentMenu;
- protected bool m_IsOpen;
- void ModsMenuDetailedEntry(ModInfo data, Widget parent, ModsMenuDetailed parent_menu)
- {
- m_Root = GetGame().GetWorkspace().CreateWidgets("gui/layouts/new_ui/mods_menu/mods_menu_detailed_entry.layout", parent);
- m_Detail = m_Root.FindAnyWidget("DetailContainer");
-
- m_IconSmall = ImageWidget.Cast(m_Root.FindAnyWidget("IconSmall"));
- m_IconCollapse = ImageWidget.Cast(m_Root.FindAnyWidget("collapse_button"));
- m_IconCollapse.LoadImageFile( 1, "set:dayz_gui image:icon_open" );
- m_Name = TextWidget.Cast(m_Root.FindAnyWidget("Name"));
-
- m_IconBig = ImageWidget.Cast(m_Root.FindAnyWidget("IconBig"));
- m_Author = MultilineTextWidget.Cast(m_Root.FindAnyWidget("Author"));
- m_Author.SetLineBreakingOverride(LinebreakOverrideMode.LINEBREAK_WESTERN);
-
- m_Version = TextWidget.Cast(m_Root.FindAnyWidget("Version"));
- m_ActionWebsite = RichTextWidget.Cast(m_Root.FindAnyWidget("Link"));
- m_ActionPurchase = RichTextWidget.Cast(m_Root.FindAnyWidget("Purchase"));
- #ifdef PLATFORM_PS4
- m_ActionPurchase.SetText("#mod_detail_info_store_PS");
- #endif
- #ifdef PLATFORM_XBOX
- m_ActionPurchase.SetText("#mod_detail_info_store_Xbox");
- #endif
-
- m_Description = RichTextWidget.Cast(m_Root.FindAnyWidget("Description"));
-
- m_Data = data;
- m_ParentMenu = parent_menu;
-
- m_Root.SetHandler(this);
- LoadData();
- }
-
- void ~ModsMenuDetailedEntry()
- {
- delete m_Root;
- }
-
- Widget GetWidget()
- {
- return m_Root;
- }
-
- void Select()
- {
- m_Root.SetColor( ARGBF( m_Root.GetAlpha(), 0.3, 0, 0 ) );
-
- m_Detail.Show(true);
- m_IconBig.Show( true );
- m_IconSmall.Show( false );
- m_IconCollapse.SetImage( 1 );
- m_Detail.Update();
- m_Root.Update();
- m_IsOpen = true;
- }
-
- void Deselect()
- {
- m_Root.SetColor( ARGBF( m_Root.GetAlpha(), 0.2, 0.2, 0.2 ) );
-
- m_Detail.Show(false);
- m_IconBig.Show( false );
- m_IconSmall.Show( true );
- m_IconCollapse.SetImage( 0 );
- m_Detail.Update();
- m_Root.Update();
- m_IsOpen = false;
- }
- void LoadData()
- {
- string picture = m_Data.GetPicture();
- string logo = m_Data.GetLogoSmall();
- string name = m_Data.GetName();
- string description = m_Data.GetOverview();
- string author = m_Data.GetAuthor();
- string version = m_Data.GetVersion();
- string action = m_Data.GetAction();
- //Load Large Icon
- if (picture != "")
- {
- m_IconBig.LoadImageFile(0, picture);
- }
- else if (logo != "")
- {
- m_IconBig.LoadImageFile(0, logo);
- }
- else
- {
- m_IconBig.LoadImageFile(0, ModInfo.DEFAULT_PICTURE);
- }
-
- //Load Small Icon
- if (logo != "")
- {
- m_IconSmall.LoadImageFile(0, logo);
- }
- else if (picture != "")
- {
- m_IconSmall.LoadImageFile(0, picture);
- }
- else
- {
- m_IconSmall.LoadImageFile(0, ModInfo.DEFAULT_LOGO_SMALL);
- }
- if (name != "")
- {
- m_Name.SetText(name);
- }
- if (description != "")
- {
- m_Description.SetText(description);
- }
- else
- {
- m_Description.SetText(ModInfo.DEFAULT_OVERVIEW);
- }
- m_Description.Update();
- m_Detail.Update();
-
- if (author != "")
- {
- m_Author.Show( true );
- m_Author.SetText(author);
- }
-
- if (version != "")
- {
- m_Version.Show( true );
- m_Version.SetText(version);
- }
-
- #ifdef PLATFORM_WINDOWS
- if (action != "")
- {
- m_ActionWebsite.Show( true );
- }
- #endif
-
- if ( m_Data.GetIsDLC() )
- {
- bool isOwned = m_Data.GetIsOwned();
- m_Root.FindAnyWidget("ModOwnership").Show( true );
- m_Root.FindAnyWidget("Owned").Show( isOwned );
- m_Root.FindAnyWidget("Unowned").Show( !isOwned );
- m_ActionPurchase.Show( true );
- m_Version.Show( false );
- }
- }
-
- override bool OnMouseButtonUp(Widget w, int x, int y, int button)
- {
- if (w == m_IconCollapse)
- {
- m_ParentMenu.Select(m_Data, !m_IsOpen);
- return true;
- }
- else if (w == m_ActionWebsite)
- {
- GetGame().OpenURL(m_Data.GetAction());
- }
- else if (w == m_ActionPurchase)
- {
- m_Data.GoToStore();
- }
- return false;
- }
-
- override bool OnMouseEnter(Widget w, int x, int y)
- {
- if (w == m_ActionWebsite)
- m_ActionWebsite.SetBold(true);
-
- if (w == m_ActionPurchase)
- m_ActionPurchase.SetBold(true);
-
- if (w == m_Root)
- {
- if (m_Data.GetTooltip() != "")
- m_ParentMenu.PrepareTooltip(m_Data);
- return true;
- }
-
- return false;
- }
-
- override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
- {
- if (w == m_ActionWebsite)
- m_ActionWebsite.SetBold(false);
-
- if (w == m_ActionPurchase)
- m_ActionPurchase.SetBold( false );
-
- if (enterW != m_Root)
- {
- m_ParentMenu.HideTooltip();
- return true;
- }
-
- return false;
- }
- }
|