consoletoolbarhandler.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. class ConsoleToolbarWidgetHandlerBase : ScriptedWidgetEventHandler
  2. {
  3. Widget m_ToolbarWidget; //'toolbar_bg'
  4. RichTextWidget m_ToolbarText;
  5. void OnWidgetScriptInit(Widget w)
  6. {
  7. m_ToolbarWidget = w;
  8. m_ToolbarWidget.SetHandler(this);
  9. m_ToolbarText = RichTextWidget.Cast(m_ToolbarWidget.FindAnyWidget("ContextToolbarText"));
  10. #ifdef PLATFORM_CONSOLE
  11. if (GetGame().GetMission())
  12. {
  13. GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
  14. }
  15. #endif
  16. UpdateControlsElements();
  17. }
  18. protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
  19. {
  20. #ifdef PLATFORM_CONSOLE
  21. UpdateControlsElements(pInputDeviceType);
  22. #endif
  23. }
  24. protected void UpdateControlsElements(EInputDeviceType pInputDeviceType = EInputDeviceType.UNKNOWN)
  25. {
  26. #ifndef PLATFORM_CONSOLE
  27. m_ToolbarWidget.Show(false);
  28. #endif
  29. }
  30. }
  31. class PasswordMenuToolbarHandler : ConsoleToolbarWidgetHandlerBase
  32. {
  33. override protected void UpdateControlsElements(EInputDeviceType pInputDeviceType = EInputDeviceType.UNKNOWN)
  34. {
  35. #ifdef PLATFORM_CONSOLE
  36. string text = "";
  37. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlY", "#server_browser_show / #server_browser_hide", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  38. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUICtrlX", "#server_browser_menu_connect", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  39. text += string.Format(" %1",InputUtils.GetRichtextButtonIconFromInputAction("UAUIBack", "#STR_settings_menu_root_toolbar_bg_ConsoleToolbar_Back_BackText0", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
  40. m_ToolbarText.SetText(text);
  41. bool toolbarShow = false;
  42. if (pInputDeviceType == EInputDeviceType.UNKNOWN)
  43. {
  44. toolbarShow = !GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer() || GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER;
  45. }
  46. else
  47. {
  48. toolbarShow = pInputDeviceType == EInputDeviceType.CONTROLLER;
  49. }
  50. m_ToolbarWidget.Show(toolbarShow);
  51. #endif
  52. }
  53. };