InterfaceUtils.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #pragma once
  2. //#ifndef _InterfaceUtils_h_
  3. #include "..\..\..\common_h\mission.h"
  4. class InterfaceUtils : public Service
  5. {
  6. public:
  7. InterfaceUtils();
  8. virtual ~InterfaceUtils();
  9. //Рисовать ли UI
  10. inline static bool IsHide()
  11. {
  12. if(largeshot && largeshot->Get(0) != 0)
  13. {
  14. return true;
  15. }
  16. if(hideHUD && hideHUD->Get(0) != 0)
  17. {
  18. return true;
  19. }
  20. return false;
  21. }
  22. inline static float AspectRatio(IRender & render)
  23. {
  24. // return 1.0f;
  25. // const RENDERVIEWPORT &vp = render.GetViewport(); return vp.Width/float(vp.Height);
  26. // return render.IsWideScreen() ? 1.3333333333f : 1.0f;
  27. //JOKER:
  28. //return render.IsWideScreen() ? 1.0f : 1.3333333333f;
  29. return render.GetWideScreenAspectWidthMultipler();
  30. /* const RENDERVIEWPORT &wp = render.GetFullScreenViewPort();
  31. bool wideScreen = render.IsWideScreen() || wp.Height/float(wp.Width) < 0.7f;
  32. return wideScreen ? 1.3333333333f : 1.0f;*/
  33. // const RENDERVIEWPORT &vp = render.GetViewport();
  34. // return vp.Width/float(vp.Height) > 1.5f ? 16.0f/9.0f : 1.0f;
  35. }
  36. inline static dword HideFieldSize(IRender & render)
  37. {
  38. return 0;
  39. }
  40. inline static float ScreenCoord2UIRectCoord(float t) // 0 <= t <= 1
  41. {
  42. #ifdef _XBOX
  43. /*
  44. const float safeZone = 0.05f; // 5% от каждой стороны экрана
  45. return safeZone + t*(1.0f - 2.0f*safeZone);
  46. */
  47. return t;
  48. #else
  49. return t;
  50. #endif
  51. }
  52. inline static float ScreenSize2UIRectSize(float size) // 0 <= t <= 1
  53. {
  54. #ifdef _XBOX
  55. /*
  56. const float safeZone = 0.05f; // 5% от каждой стороны экрана
  57. return size*(1.0f - 2.0f*safeZone);
  58. */
  59. return size;
  60. #else
  61. return size;
  62. #endif
  63. }
  64. inline static const ConstString & GetCursorName()
  65. {
  66. static const ConstString cursorName("Cursor");
  67. return cursorName;
  68. }
  69. inline static const ConstString & GetBaseId()
  70. {
  71. static const ConstString baseId("BaseGUIElement");
  72. return baseId;
  73. }
  74. inline static const ConstString & GetButtonId()
  75. {
  76. static const ConstString buttonId("GUIButton");
  77. return buttonId;
  78. }
  79. inline static const ConstString & GetSliderId()
  80. {
  81. static const ConstString sliderId("GUISlider");
  82. return sliderId;
  83. }
  84. inline static const ConstString & GetPbarId()
  85. {
  86. static const ConstString pbarId("csProgressBar");
  87. return pbarId;
  88. };
  89. inline static const ConstString & GetWidgetId()
  90. {
  91. static const ConstString widgetId("GUIWidget");
  92. return widgetId;
  93. };
  94. // заменяет пробелы на '\n' в местах где надо сделать перенос
  95. static dword WordWrapString(string &str, IFont *font, float outputPixelWidth);
  96. static dword WordWrapString(char text[], IFont *font, float outputPixelWidth, dword textMaxSize);
  97. static ICoreStorageLong * largeshot;
  98. static ICoreStorageLong * hideHUD;
  99. };
  100. //#endif