Editor.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #include "Editor.h"
  2. #include <Rahmen.h>
  3. #include "../../Global/Variablen.h"
  4. #include <InitDatei.h>
  5. // Inhalt der Editor Klasse aus Editor.h
  6. // Konstruktor
  7. Editor::Editor( Fenster *zNachLoginFenster, int x )
  8. : Zeichnung()
  9. {
  10. bildschirmGröße = uiFactory.initParam.bildschirm->getBackBufferSize();
  11. pos = Punkt( x, 35 );
  12. gr = Punkt( 102, 32 );
  13. rahmen = new LRahmen();
  14. rahmen->setFarbe( 0xFFFFFFFF );
  15. rahmen->setSize( 102, 32 );
  16. alpha = 0;
  17. animation = 0;
  18. sichtbar = 0;
  19. tickVal = 0;
  20. jetzt = 0;
  21. prozent1 = 0;
  22. prozent2 = 0;
  23. begPos = Punkt( 0, 0 );
  24. begGröße = Punkt( 0, 0 );
  25. größe1 = Punkt( 102, 32 );
  26. pos1 = Punkt( x, 35 );
  27. größe2 = Punkt( 900, 600 );
  28. pos2 = bildschirmGröße / 2 - größe2 / 2;
  29. laden = (Animation2D *)ladeAnimation->dublizieren();
  30. laden->setSichtbar( 0 );
  31. laden->setPosition( 425, 275 );
  32. getThis();
  33. zNachLoginFenster->addMember( this );
  34. kEditor = new KartenEditor();
  35. karteAuswahl = new Auswahl( dynamic_cast<KartenEditor *>( kEditor->getThis() ) );
  36. }
  37. // Destruktor
  38. Editor::~Editor()
  39. {
  40. karteAuswahl->warteAufThread( 10000 );
  41. karteAuswahl->ende();
  42. kEditor->warteAufThread( 10000 );
  43. kEditor->ende();
  44. kEditor->release();
  45. rahmen->release();
  46. laden->release();
  47. karteAuswahl->release();
  48. }
  49. // nicht constant
  50. void Editor::setSichtbar( bool sicht )
  51. {
  52. begPos = pos;
  53. begGröße = gr;
  54. animation |= ( sicht ? 0x1 : 0x2 );
  55. rend = 1;
  56. }
  57. void Editor::doPublicMausEreignis( MausEreignis &me )
  58. {
  59. if( animation || !sichtbar )
  60. return;
  61. me.mx -= pos.x;
  62. me.my -= pos.y;
  63. switch( jetzt )
  64. {
  65. case 1: // Karten Auswahl
  66. karteAuswahl->doPublicMausEreignis( me );
  67. break;
  68. case 2: // Karten Editor
  69. kEditor->doPublicMausEreignis( me );
  70. break;
  71. }
  72. me.mx += pos.x;
  73. me.my += pos.y;
  74. }
  75. void Editor::doTastaturEreignis( TastaturEreignis &te )
  76. {
  77. if( animation || !sichtbar )
  78. return;
  79. switch( jetzt )
  80. {
  81. case 1: // Karten Auswahl
  82. karteAuswahl->doTastaturEreignis( te );
  83. break;
  84. case 2: // Karten Editor
  85. kEditor->doTastaturEreignis( te );
  86. break;
  87. }
  88. }
  89. bool Editor::tick( double z )
  90. {
  91. rend |= laden->tick( z );
  92. rend |= karteAuswahl->tick( z );
  93. if( jetzt == 1 && !karteAuswahl->istSichtbar() )
  94. {
  95. kEditor->setSichtbar( 1 );
  96. jetzt = 2;
  97. }
  98. if( jetzt == 2 && !kEditor->istSichtbar() )
  99. {
  100. karteAuswahl->setSichtbar( 1 );
  101. jetzt = 1;
  102. }
  103. rend |= kEditor->tick( z );
  104. tickVal += z * 150;
  105. int val = (int)tickVal;
  106. if( val < 1 )
  107. {
  108. bool ret = rend;
  109. rend = 0;
  110. return ret;
  111. }
  112. tickVal -= val;
  113. if( ( animation | 0x1 ) == animation ) // Einblenden
  114. {
  115. if( prozent1 != 100 )
  116. {
  117. prozent1 += val;
  118. if( prozent1 >= 100 )
  119. {
  120. if( !jetzt )
  121. {
  122. karteAuswahl->setSichtbar( 1 );
  123. jetzt = 1;
  124. }
  125. prozent1 = 100;
  126. }
  127. pos = begPos + (Punkt)( ( ( Vec2< double > )( pos2 - begPos ) / 100.0 ) * prozent1 );
  128. gr = begGröße + (Punkt)( ( ( Vec2< double > )( größe2 - begGröße ) / 100.0 ) * prozent1 );
  129. }
  130. else if( alpha != 255 )
  131. {
  132. alpha += val * 2;
  133. if( alpha >= 255 || ( animation | 0x2 ) == animation )
  134. {
  135. alpha = 255;
  136. animation &= ~0x1;
  137. sichtbar = 1;
  138. prozent1 = 0;
  139. }
  140. }
  141. rend = 1;
  142. }
  143. if( ( animation | 0x2 ) == animation ) // ausblenden
  144. {
  145. if( alpha != 0 )
  146. {
  147. alpha -= val * 2;
  148. if( alpha < 0 )
  149. alpha = 0;
  150. }
  151. else
  152. {
  153. prozent2 += val;
  154. if( prozent2 > 100 )
  155. prozent2 = 100;
  156. pos = begPos + (Punkt)( ( ( Vec2< double > )( pos1 - begPos ) / 100.0 ) * prozent2 );
  157. gr = begGröße + (Punkt)( ( ( Vec2< double > )( größe1 - begGröße ) / 100.0 ) * prozent2 );
  158. if( prozent2 == 100 )
  159. {
  160. prozent2 = 0;
  161. animation &= ~0x2;
  162. sichtbar = 0;
  163. }
  164. }
  165. rend = 1;
  166. }
  167. bool ret = rend;
  168. rend = 0;
  169. return ret;
  170. }
  171. void Editor::render( Bild &zRObj )
  172. {
  173. if( pos == pos1 )
  174. return;
  175. if( !zRObj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
  176. return;
  177. rahmen->setSize( gr );
  178. rahmen->render( zRObj );
  179. int rbr = rahmen->getRBreite();
  180. zRObj.setAlpha( (unsigned char)alpha );
  181. karteAuswahl->render( zRObj );
  182. kEditor->render( zRObj );
  183. laden->render( zRObj );
  184. zRObj.releaseAlpha();
  185. zRObj.releaseDrawOptions();
  186. }
  187. // constant
  188. bool Editor::istAnimiert() const
  189. {
  190. return animation != 0;
  191. }
  192. bool Editor::istSichtbar() const
  193. {
  194. return sichtbar || prozent1 != 0;
  195. }