Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ButtonImageComponent.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
3{
4 [Attribute("", UIWidgets.ResourcePickerThumbnail, "Select edds texture or imageset", "edds imageset")]
5 ResourceName m_sTexture;
6
7 [Attribute()]
8 string m_sImageName;
9
10 ImageWidget m_wImage;
11
12 ref ScriptInvoker<Widget> m_OnMouseEnter = new ScriptInvoker();
13 ref ScriptInvoker<Widget> m_OnMouseLeave = new ScriptInvoker();
14
15 //------------------------------------------------------------------------------------------------
16 override void HandlerAttached(Widget w)
17 {
18 super.HandlerAttached(w);
19 m_wImage = ImageWidget.Cast(w.FindAnyWidget("Image"));
20 SetImage(m_sTexture, m_sImageName);
21 }
22
23 //------------------------------------------------------------------------------------------------
24 override bool OnMouseEnter(Widget w, int x, int y)
25 {
26 super.OnMouseEnter(w, x, y);
27
28 m_OnMouseEnter.Invoke(w);
29
30 return false;
31 }
32
33 //------------------------------------------------------------------------------------------------
34 override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
35 {
36 super.OnMouseLeave(w, enterW, x, y);
37
38 m_OnMouseLeave.Invoke(w);
39
40 return false;
41 }
42
43 //------------------------------------------------------------------------------------------------
44 ImageWidget GetImageWidget()
45 {
46 return m_wImage;
47 }
48
49 //------------------------------------------------------------------------------------------------
50 void SetImage(ResourceName texture, bool fromLocalStorage = false)
51 {
52 if (!m_wImage)
53 return;
54
55 bool show = texture != string.Empty;
56 m_wImage.SetVisible(show);
57 if (show)
58 {
59 int x, y;
60 m_wImage.LoadImageTexture(0, texture, false, fromLocalStorage);
61 m_wImage.GetImageSize(0, x, y);
62 m_wImage.SetSize(x, y);
63 }
64
65 m_sTexture = texture;
66 }
67
68 //------------------------------------------------------------------------------------------------
69 void SetImageSaturation(float saturation)
70 {
71 m_wImage.SetSaturation(saturation);
72 }
73
74 //------------------------------------------------------------------------------------------------
75 float GetImageSaturation()
76 {
77 return m_wImage.GetSaturation();
78 }
79
80 //------------------------------------------------------------------------------------------------
81 void SetImage(ResourceName imageSet, string imageName)
82 {
83 if (!m_wImage)
84 return;
85
86 bool show = imageSet != string.Empty;
87 m_wImage.SetVisible(show);
88
89 if (!show)
90 return;
91
92 if (imageSet.EndsWith("imageset"))
93 m_wImage.LoadImageFromSet(0, imageSet, imageName);
94 else
95 m_wImage.LoadImageTexture(0, imageSet);
96
97 // Resize
98 int x, y;
99 m_wImage.GetImageSize(0, x, y);
100 m_wImage.SetSize(x, y);
101
102 m_sTexture = imageSet;
103 m_sImageName = imageName;
104 }
105
106 //------------------------------------------------------------------------------------------------
107 string GetImage(out string imageSet)
108 {
109 if (m_sImageName == string.Empty)
110 return m_sTexture;
111 imageSet = m_sTexture;
112 return m_sImageName;
113 }
114
115 //------------------------------------------------------------------------------------------------
116 static SCR_ButtonImageComponent GetButtonImage(string name, Widget parent, bool searchAllChildren = true)
117 {
118 auto comp = SCR_ButtonImageComponent.Cast(
119 SCR_WLibComponentBase.GetComponent(SCR_ButtonImageComponent, name, parent, searchAllChildren)
120 );
121 return comp;
122 }
123};
Base class for any button, regardless its own content.
Base class for all final Reforger interactive elements.
SCR_FieldOfViewSettings Attribute
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134