18 enum EModularButtonInputDevice
29 class SCR_ButtonEffectBase
31 [
Attribute(
"true", UIWidgets.CheckBox,
"Enables this effect")]
34 [
Attribute(
"", UIWidgets.EditBox,
"Array of tags, can be used to find this effect or manipulate many effects at a time")]
35 ref array<string> m_aTags;
40 [
Attribute(
"63", UIWidgets.Flags,
"Input devices which can trigger this effect.",
"", ParamEnumArray.FromEnum(EModularButtonInputDevice)) ]
41 EModularButtonInputDevice m_eInputDevices;
43 protected SCR_ModularButtonComponent m_Button;
58 #ifdef DEBUG_MODULAR_BUTTON
59 _print(
string.Format(
"SetEnabled: %1", enabled));
65 if (enabled != enabledPrev)
68 m_Button.Internal_OnEffectEnabled(
this);
76 void PropertiesChanged()
80 m_Button.Internal_OnEffectEnabled(
this);
86 bool HasTag(
string tag)
88 return m_aTags.Contains(tag);
101 protected void OnClicked(
bool instant);
112 void OnHandlerAttached(Widget w);
127 #ifdef DEBUG_MODULAR_BUTTON
128 _print(
string.Format(
"Internal_OnEvent: %1, %2, %3",
typename.EnumToString(
EModularButtonEventFlag, eventFlag),
typename.EnumToString(EInputDeviceType, deviceType), instant));
135 EModularButtonInputDevice deviceFlag;
138 case EInputDeviceType.KEYBOARD: deviceFlag = EModularButtonInputDevice.KEYBOARD;
break;
139 case EInputDeviceType.MOUSE: deviceFlag = EModularButtonInputDevice.MOUSE;
break;
140 case EInputDeviceType.GAMEPAD: deviceFlag = EModularButtonInputDevice.GAMEPAD;
break;
141 case EInputDeviceType.JOYSTICK: deviceFlag = EModularButtonInputDevice.JOYSTICK;
break;
145 if ((deviceFlag & m_eInputDevices) == 0)
147 #ifdef DEBUG_MODULAR_BUTTON
148 _print(
"Event ignored: device input type doesn't match.");
155 if (eventFlag & m_eEvents)
157 #ifdef DEBUG_MODULAR_BUTTON
187 void Init(SCR_ModularButtonComponent parentButton)
189 m_Button = parentButton;
193 protected void _print(
string s)
197 foreach (
string tag : m_aTags)
199 tagsStr = tagsStr +
string.Format(
"'%1' ", tag);
202 m_Button._print(
string.Format(
"Effect %1 %2: %3",
this, tagsStr, s));
208 class SCR_ButtonEffectWidgetBase : SCR_ButtonEffectBase
210 [
Attribute(
"", UIWidgets.Auto,
"Widget name to apply the effect on")]
211 protected string m_sWidgetName;
213 protected Widget m_wTarget;
216 override void OnHandlerAttached(Widget w)
218 if (!m_sWidgetName.IsEmpty())
219 m_wTarget = w.FindAnyWidget(m_sWidgetName);
224 Widget GetTargetWidget()
232 class SCR_ButtonEffectTitleAttribute : BaseContainerCustomTitle
234 protected string m_sTypeStr;
235 protected string m_sVarName;
241 void SCR_ButtonEffectTitleAttribute(
string typeStr,
string varName)
243 m_sTypeStr = typeStr;
244 m_sVarName = varName;
253 source.Get(
"m_bEnabled", enabled);
262 source.Get(
"m_eEvents", events);
266 while (flag != endFlag)
271 strFlags = strFlags +
", ";
275 strFlags = strFlags + enumStr;
285 source.Get(
"m_aTags", tags);
288 foreach (
string t : tags)
290 strTags = strTags +
string.Format(
"'%1' ", t);
294 string targetWidgetName;
295 if (!m_sVarName.IsEmpty())
299 source.Get(m_sVarName, targetWidgetName);
303 if (!targetWidgetName.IsEmpty())
304 strOut =
string.Format(
"%1 %2: %3 %4 (%5)", strEnabled, m_sTypeStr, strTags, targetWidgetName, strFlags);
306 strOut =
string.Format(
"%1 (E) %2: %3 Widget name not specified!", strEnabled, m_sTypeStr, strTags);
314 title =
string.Format(
"%1 %2: %3 (%4)", strEnabled, m_sTypeStr, strTags, strFlags);