Controls.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. /******************************************************************************/
  4. Rotator Rot;
  5. Edit::Viewport4::DPad DPad;
  6. Edit::Viewport4::DPadY DPadY;
  7. Edit::Viewport4::Zoom Zoom;
  8. Button ExitButton;
  9. /******************************************************************************/
  10. void InitGameButtons()
  11. {
  12. if(SupportedTouches())
  13. {
  14. Gui+=ExitButton.create(Rect_LU(-D.w(), D.h(), 0.15f, 0.07f), "Exit").func(ExitGame).focusable(false);
  15. flt y=Lerp(-D.h(), D.h(), 0.4f);
  16. Gui+=DPadY .create(null, null).rect(Rect_L(-D.w() , y, 0.08f, 0.23f));
  17. Gui+=DPad .create(null, null).rect(Rect_L(-D.w()+0.09f, y, 0.23f, 0.23f));
  18. Gui+=Rot .create( ).rect(Rect_R( D.w()-0.09f, y, 0.23f, 0.23f));
  19. Gui+=Zoom .create(null, null).rect(Rect_R( D.w() , y, 0.08f, 0.23f));
  20. }
  21. }
  22. /******************************************************************************/
  23. void ShutGameButtons()
  24. {
  25. ExitButton.del();
  26. DPad .del();
  27. DPadY .del();
  28. Rot .del();
  29. Zoom .del();
  30. }
  31. /******************************************************************************/
  32. void GameScreenChanged()
  33. {
  34. ExitButton.pos(Vec2(-D.w(), D.h()));
  35. flt y=Lerp(-D.h(), D.h(), 0.4f);
  36. Vec2 d=Vec2(-D.w(), y)-DPadY.rect().left();
  37. DPadY.move(d);
  38. DPad .move(d);
  39. d=Vec2(D.w(), y)-Zoom.rect().right();
  40. Zoom.move(d);
  41. Rot .move(d);
  42. }
  43. /******************************************************************************/
  44. /******************************************************************************/
  45. GuiObj* Rotator::test(C GuiPC &gpc, C Vec2 &pos, GuiObj* &mouse_wheel)
  46. {
  47. return Cuts(pos, Circle(rect().h()*0.5f, rect().center()+gpc.offset)) ? ::EE::GuiObj::test(gpc, pos, mouse_wheel) : null;
  48. }
  49. void Rotator::update(C GuiPC &gpc)
  50. {
  51. ::EE::GuiObj::update(gpc);
  52. delta=0; if(Gui.ms()==this && Ms.b(0)){delta+=Ms.d(); Ms.freeze();} REPA(Touches)if(Touches[i].guiObj()==this && Touches[i].on())delta+=Touches[i].ad()*3;
  53. }
  54. void Rotator::draw(C GuiPC &gpc)
  55. {
  56. if(visible() && gpc.visible)
  57. {
  58. D.clip(gpc.clip);
  59. Circle circle(rect().h()*0.5f, rect().center()+gpc.offset);
  60. circle.draw(Color(192, 200, 232, 64));
  61. circle.draw(Color(0, 0, 0, 128), false);
  62. }
  63. }
  64. Rotator::Rotator() : delta(0) {}
  65. /******************************************************************************/