Editor.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #include "Editor.h"
  2. #include <iostream>
  3. // Inhalt der Editor Klasse aus Editor.h
  4. // Konstruktor
  5. Editor::Editor()
  6. {
  7. schrift = 0;
  8. klient = 0;
  9. laden = 0;
  10. i = 0;
  11. alpha = 0;
  12. verlassen = 0;
  13. dialogs = new Array< Dialog* >();
  14. rend = 1;
  15. ref = 1;
  16. }
  17. // Destruktor
  18. Editor::~Editor()
  19. {
  20. if( schrift )
  21. schrift->release();
  22. if( klient )
  23. klient->release();
  24. if( laden )
  25. laden->release();
  26. if( i )
  27. i->release();
  28. }
  29. // nicht constant
  30. void Editor::setSchrift( Schrift *schrift )
  31. {
  32. if( this->schrift )
  33. this->schrift->release();
  34. this->schrift = schrift;
  35. if( !i )
  36. i = new Interface( schrift );
  37. }
  38. void Editor::setKlient( EditorKlientV *ekv )
  39. {
  40. if( klient )
  41. klient->release();
  42. klient = new EditorKlient( ekv );
  43. }
  44. void Editor::setLadeAnimation( Animation2D *la )
  45. {
  46. if( laden )
  47. laden->release();
  48. laden = la;
  49. }
  50. void Editor::setSichtbar()
  51. {
  52. verlassen = 0;
  53. rend = 1;
  54. }
  55. void Editor::doMausEreignis( MausEreignis &me )
  56. {
  57. for( auto i = dialogs->getArray(); i.set && i.var; i++ )
  58. i.var->doMausEreignis( me );
  59. i->doMausEreignis( me );
  60. verlassen = i->hatVerlassen();
  61. }
  62. void Editor::doTastaturEreignis( TastaturEreignis &te )
  63. {
  64. for( auto i = dialogs->getArray(); i.set && i.var; i++ )
  65. i.var->doTastaturEreignis( te );
  66. i->doTastaturEreignis( te );
  67. }
  68. bool Editor::tick( double z )
  69. {
  70. rend |= i->tick( z );
  71. for( auto i = dialogs->getArray(); i.set && i.var; i++ )
  72. rend |= i.var->tick( z );
  73. bool tmp = rend;
  74. rend = 0;
  75. return tmp;
  76. }
  77. void Editor::render( Bild &zRObj )
  78. {
  79. i->render( zRObj );
  80. for( int i = dialogs->getEintragAnzahl() - 1; i >= 0; i-- )
  81. {
  82. dialogs->get( i )->render( zRObj );
  83. if( dialogs->get( i )->hatVerlassen() )
  84. {
  85. delete dialogs->get( i );
  86. dialogs->remove( i );
  87. }
  88. }
  89. }
  90. // constant
  91. bool Editor::hatVerlassen( bool jetzt ) const
  92. {
  93. return verlassen;
  94. }
  95. // Reference Counting
  96. EditorV *Editor::getThis()
  97. {
  98. ref++;
  99. return this;
  100. }
  101. EditorV *Editor::release()
  102. {
  103. ref--;
  104. if( !ref )
  105. delete this;
  106. return 0;
  107. }