plugindrawcheckerboard.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // quick and dirty way for displaying of checker overlay on screen
  2. // - userd for camera settings primarily
  3. class PluginDrawCheckerboard extends PluginBase
  4. {
  5. private ref Widget m_MainWindow;
  6. private bool m_IsActive;
  7. void PluginDrawCheckerboard()
  8. {
  9. CreateWidgetOverlay();
  10. }
  11. void ~PluginDrawCheckerboard() {}
  12. void CreateWidgetOverlay()
  13. {
  14. #ifndef NO_GUI
  15. if (!m_MainWindow)
  16. {
  17. m_MainWindow = GetGame().GetWorkspace().CreateWidgets("gui/layouts/camera_checkerboard.layout");
  18. m_MainWindow.Show(false);
  19. int childId = 0;
  20. int row = 0;
  21. bool evenOrOdd;
  22. int tilesPerLine = 8;
  23. Widget child = m_MainWindow.GetChildren();
  24. while(child)
  25. {
  26. evenOrOdd = IsEven(childId);
  27. //! row counter
  28. if(childId > (tilesPerLine * row) - 1)
  29. {
  30. row++;
  31. }
  32. if(IsEven(row))
  33. {
  34. evenOrOdd = !evenOrOdd;
  35. }
  36. //! sets alpha level for even/odd child
  37. if(evenOrOdd)
  38. child.SetAlpha(0.15);
  39. else
  40. child.SetAlpha(0.05);
  41. child = child.GetSibling();
  42. childId++;
  43. }
  44. }
  45. #endif
  46. }
  47. bool IsActive()
  48. {
  49. return m_IsActive;
  50. }
  51. //! even or odd
  52. bool IsEven(int num)
  53. {
  54. if((num % 2) == 0)
  55. return true;
  56. else
  57. return false;
  58. }
  59. void ShowWidgets(bool show)
  60. {
  61. if(m_MainWindow)
  62. {
  63. m_MainWindow.Show(show);
  64. }
  65. }
  66. //!
  67. void Show()
  68. {
  69. ShowWidgets(true);
  70. m_IsActive = true;
  71. }
  72. //!
  73. void Hide()
  74. {
  75. ShowWidgets(false);
  76. m_IsActive = false;
  77. }
  78. }