9 const int ITEMS_COUNT = 27;
27 if (!m_context_menu_root_widget)
30 m_context_menu_panel_widget = m_context_menu_root_widget.FindAnyWidget(
"PanelWidget");
31 m_context_menu_root_widget.Show(
false);
32 m_context_menu_root_widget.SetHandler(
this);
39 if ( m_count == 0)
return;
40 int screen_w, screen_h;
49 float button_height_percent = 0.02;
50 float button_height = screen_h * button_height_percent;
52 for (
int i = 0; i <
m_count; i++)
54 ButtonWidget menu_button = ButtonWidget.Cast( m_context_menu_root_widget.FindAnyWidget(
String(
"Button" + (i+1).
ToString() ) ) );
57 menu_button.SetSize(0.90, button_height);
58 menu_button.Show(
true);
64 m_context_menu_panel_widget.GetScript(spacer);
70 m_context_menu_root_widget.GetSize(w, h);
71 m_context_menu_panel_widget.GetSize(sx, sy);
72 m_context_menu_root_widget.SetSize(w, sy);
75 m_context_menu_root_widget.GetScreenSize(w,h);
79 int right_edge =
x + w - offset_x;
80 if (right_edge > screen_w)
82 x = screen_w - w - offset_x;
89 int bottom_edge =
y + h - offset_y;
90 if (bottom_edge > screen_h)
99 m_context_menu_root_widget.SetPos(
x,
y);
100 m_context_menu_root_widget.Show(
true);
108 m_context_menu_root_widget.FindAnyWidget(
"BackdropImageWidget").Show(
true);
112 m_context_menu_root_widget.FindAnyWidget(
"BackdropImageWidget").Show(
false);
119 m_context_menu_root_widget.Show(
false);
127 return m_context_menu_root_widget.IsVisible();
133 super.OnMouseLeave(w, enterW,
x,
y);
135 if ( enterW && m_context_menu_panel_widget && enterW != m_context_menu_panel_widget && enterW.GetParent() != m_context_menu_panel_widget )
146 super.OnMouseButtonDown(w,
x,
y, button);
148 if (button ==
MouseState.LEFT && w.GetUserID() > -1 && w.GetUserID() < m_commands.Count())
152 int actionId = Param3<ItemBase, int, int>.Cast(ctx.
m_params).param2;
171 AddEx(label, FadeColors.LIGHT_GREY, obj, fn_name, params);
177 ButtonWidget menuButton = ButtonWidget.Cast(m_context_menu_root_widget.FindAnyWidget(
string.Format(
"Button%1", count + 1)));
181 menuButton.SetText(label);
182 menuButton.SetTextColor(labelColor);
183 menuButton.Show(
true);
185 menuButton.SetFlags(menuButton.GetFlags() |
WidgetFlags.IGNOREPOINTER);
187 int itemWidth = label.
Length();
188 if (m_max_item_width < itemWidth)
189 m_max_item_width = itemWidth;
199 if (index < m_commands.Count())
201 m_commands.RemoveOrdered(index);
202 ButtonWidget menu_button = ButtonWidget.Cast( m_context_menu_root_widget.FindAnyWidget(
String(
"Button" + ( index + 1 ).
ToString() ) ) );
203 menu_button.Show(
false );
204 menu_button.SetText(
"" );
212 return m_commands.Count();
222 Widget child = m_context_menu_panel_widget.GetChildren();
225 ButtonWidget button = ButtonWidget.Cast(child);
230 child = child.GetSibling();
235 m_max_item_width = 0;
override ScriptCallQueue GetCallQueue(int call_category)
proto native UIManager GetUIManager()
proto native WorkspaceWidget GetWorkspace()
Super root of all classes in Enforce script.
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
proto void Call(func fn, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
proto native UIScriptedMenu GetMenu()
Returns most-top open menu.
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
string String(string s)
Helper for passing string expression to functions with void parameter. Example: Print(String("Hello "...
proto void GetScreenSize(out int x, out int y)
proto int ToUpper()
Changes string to uppercase. Returns length.
proto native int Length()
Returns length of string.