Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WidgetHighlightUIComponent.c
Go to the documentation of this file.
2{
4
12 static Widget CreateHighlight(Widget widget, ResourceName layout, Widget parent = null)
13 {
14 if (!widget)
15 {
16 Print("Cannot create highlight, widget not found!", LogLevel.WARNING);
17 return null;
18 }
19
20 /*
21 Create the highlight in Workspace, not where target widget is.
22 It's because we don't know which layout slot is used, and not all of them would be compatible (e.g., horizontal slot).
23 Furthermore, highlight widget can be an outline *outside* of the area, and modifying target's clipping could be dangerous.
24 */
25 WorkspaceWidget workspace = GetGame().GetWorkspace();
26 if (!parent)
27 parent = workspace;
29 highlight.m_HighlightWidget = workspace.CreateWidgets(layout, parent);
30 widget.AddHandler(highlight);
31 return highlight.m_HighlightWidget;
32 }
33
40 static Widget CreateHighlight(string widgetName, ResourceName layout, Widget parent = null)
41 {
42 Widget widget = GetGame().GetWorkspace().FindAnyWidget(widgetName);
43 if (!widget)
44 {
45 Print(string.Format("Cannot create highlight, widget '%1' not found!", widgetName), LogLevel.WARNING);
46 return null;
47 }
48 return CreateHighlight(widget, layout, parent);
49 }
50
51 protected void Update(Widget w)
52 {
53 //--- Exit if the parent was meanwhile deleted (e.g., when the menu is closed)
54 if (!m_HighlightWidget || !w.GetParent())
55 {
57 return;
58 }
59
60 WorkspaceWidget workspace = GetGame().GetWorkspace();
61
62 //--- Set position
63 float posX, posY, posW, posH;
64 w.GetScreenPos(posX, posY);
65 w.GetScreenSize(posW, posH);
66 FrameSlot.SetPos(m_HighlightWidget, workspace.DPIUnscale(posX), workspace.DPIUnscale(posY));
67 FrameSlot.SetSize(m_HighlightWidget, workspace.DPIUnscale(posW), workspace.DPIUnscale(posH));
68
69 //--- Set visibility
70 bool isVisible = true;
71 while (w)
72 {
73 if (!w.IsVisible() || w.GetOpacity() == 0)
74 {
75 isVisible = false;
76 break;
77 }
78 w = w.GetParent();
79 }
80 m_HighlightWidget.SetVisible(isVisible);
81 }
82 override void HandlerAttached(Widget w)
83 {
84 Update(w);
85 if (GetGame().GetCallqueue())
86 GetGame().GetCallqueue().CallLater(Update, 1, true, w);
87 }
88 override void HandlerDeattached(Widget w)
89 {
90 if (GetGame())
91 {
92 if (GetGame().GetCallqueue())
93 GetGame().GetCallqueue().Remove(Update);
94 }
95
97 m_HighlightWidget.RemoveFromHierarchy();
98 }
99};
ArmaReforgerScripted GetGame()
Definition game.c:1398
ScriptCallQueue GetCallqueue()
Returns CallQueue of this AI. It gets updated from EvaluateBehavior, so that it's synchronous with ot...
UI layouts Menus CleanSweep CleanSweepAreaSelection layout
static Widget CreateHighlight(Widget widget, ResourceName layout, Widget parent=null)
static Widget CreateHighlight(string widgetName, ResourceName layout, Widget parent=null)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14