17enum EModularButtonEventHandler
42 protected ref array<ref SCR_ButtonEffectBase>
m_aEffects;
46 [
Attribute(
"false", UIWidgets.CheckBox,
"Can the button be only clicked, or also toggled?")]
49 [
Attribute(
"false",
UIWidgets.CheckBox,
"If the button can be toggled, toggle it automatically on click or only through external API?")]
55 [
Attribute(
"2147483647",
UIWidgets.Flags,
"Value which will be returned from event handlers. Useful in button-over-button cases: tiles with buttons inside or similar.",
"", ParamEnumArray.FromEnum(EModularButtonEventHandler))]
58 [
Attribute(
"false",
UIWidgets.CheckBox,
"The button will be focused on mouse enter events")]
61 [
Attribute(
"false",
UIWidgets.CheckBox,
"Mouse over, focus, clicks, etc, will be completely ignored. Useful to create a button driven by SlaveButton effect.")]
99 static SCR_ModularButtonComponent FindComponent(
Widget w)
101 return SCR_ModularButtonComponent.Cast(w.FindHandler(SCR_ModularButtonComponent));
108 #ifdef DEBUG_MODULAR_BUTTON
109 _print(
string.Format(
"SetEnabled: %1", enabled));
126 void SetToggled(
bool toggled,
bool invokeOnToggled =
true,
bool instant =
false)
128 #ifdef DEBUG_MODULAR_BUTTON
129 _print(
string.Format(
"SetToggled: %1", toggled));
211 SCR_ButtonEffectBase FindEffect(
string tag)
215 if (e.m_aTags.Contains(tag))
227 array<SCR_ButtonEffectBase> effects = {};
230 if (e.m_aTags.Contains(tag))
241 array<SCR_ButtonEffectBase> effects = {};
256 #ifdef DEBUG_MODULAR_BUTTON
257 _print(
string.Format(
"SetEffectsEnabled: %1, %2", tag, enable));
262 if (e.m_aTags.Contains(tag))
263 e.SetEnabled(enable);
275 foreach (
string tag :
tags)
277 if (e.m_aTags.Contains(tag))
293 #ifdef DEBUG_MODULAR_BUTTON
294 _print(
string.Format(
"SetAllEffectsEnabled: %1", enable));
299 e.SetEnabled(enable);
337 #ifdef DEBUG_MODULAR_BUTTON
341 if (newState != oldState)
403 EInputDeviceType deviceType =
GetGame().GetInputManager().GetLastUsedInputDevice();
405 #ifdef DEBUG_MODULAR_BUTTON
406 _print(
string.Format(
"InvokeEffectsEvent: %1, %2",
typename.EnumToString(
EModularButtonEventFlag, eventFlag),
typename.EnumToString(EInputDeviceType, deviceType)));
409 foreach (SCR_ButtonEffectBase effect :
m_aEffects)
411 if (effect.GetEnabled())
412 effect.Internal_OnEvent(eventFlag, deviceType, instant);
432 if (newToggled != oldToggled)
442 if (invokeOnToggled && newToggled != oldToggled)
452 EInputDeviceType deviceType =
GetGame().GetInputManager().GetLastUsedInputDevice();
453 effect.Internal_OnEvent(state, deviceType,
true);
477 foreach (SCR_ButtonEffectBase effect :
m_aEffects)
480 effect.OnHandlerAttached(w);
489 array<ref Tuple3<Widget, typename, int>> widgetEffectEventMasks = {};
490 foreach (SCR_ButtonEffectBase effect :
m_aEffects)
492 SCR_ButtonEffectWidgetBase widgetEffect = SCR_ButtonEffectWidgetBase.Cast(effect);
493 if (effect.GetEnabled() && widgetEffect)
496 bool disabled =
false;
499 if (i.param1 == widgetEffect.GetTargetWidget() &&
500 i.param2 == widgetEffect.Type() &&
501 (i.param3 & widgetEffect.m_eEvents))
504 widgetEffect.SetEnabled(
false);
516 if (i.param1 == widgetEffect.GetTargetWidget() &&
517 i.param2 == widgetEffect.Type())
527 widgetEffectEventMasks.Insert(entry);
530 entry.param3 = entry.param3 | widgetEffect.m_eEvents;
542 #ifdef DEBUG_MODULAR_BUTTON
550 Widget currentFocus = workspace.GetFocusedWidget();
552 workspace.SetFocusedWidget(
m_wRoot);
558 return eventReturnValue;
570 return eventReturnValue;
586 #ifdef DEBUG_MODULAR_BUTTON
597 EInputDeviceType lastInput =
GetGame().GetInputManager().GetLastUsedInputDevice();
598 bool mouseInput = lastInput == EInputDeviceType.MOUSE;
616 #ifdef DEBUG_MODULAR_BUTTON
627 EInputDeviceType lastInput =
GetGame().GetInputManager().GetLastUsedInputDevice();
628 bool mouseInput = lastInput == EInputDeviceType.MOUSE;
640 #ifdef DEBUG_MODULAR_BUTTON
659 #ifdef DEBUG_MODULAR_BUTTON
ArmaReforgerScripted GetGame()
EAITargetClusterState m_eState
override string GetData()
override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
ref array< ref SCR_BaseEntitiesEditorUIEffect > m_aEffects
override bool OnMouseEnter(Widget w, int x, int y)
Get all prefabs that have the spawner data
void SetVisible(int layer)
override void HandlerAttached(Widget w)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
void SetEnabled(bool enabled)