NachrichtenListe.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853
  1. #include "NachrichtenListe.h"
  2. #include <Punkt.h>
  3. #include <MausEreignis.h>
  4. #include <Bild.h>
  5. #include "../../Global/Initialisierung.h"
  6. #include <Scroll.h>
  7. #include "../../Global/Variablen.h"
  8. #include <Rahmen.h>
  9. #include <DateiSystem.h>
  10. #include <KSGTDatei.h>
  11. #include <ToolTip.h>
  12. #include <GSLDateiV.h>
  13. #include <Globals.h>
  14. #include <InitDatei.h>
  15. typedef GSL::GSLDateiV *( *GetGSLDatei )( );
  16. NLNachricht::NLNachricht( Text *titel )
  17. : ReferenceCounter()
  18. {
  19. rahmen = new LRahmen();
  20. rahmen->setRamenBreite( 1 );
  21. rahmen->setFarbe( 0xFFFFFFFF );
  22. this->titel = initTextFeld( 1, 1, 208, 20, TextFeld::Style::Text | TextFeld::Style::Center, titel->getText() );
  23. titel->release();
  24. close = initKnopf( 208, 1, 20, 20, 0, "" );
  25. close->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HBild | Knopf::Style::HAlpha | Knopf::Style::KlickBuffer );
  26. Bild *closeBild = bilder->get( "data/client/bilder/chat.ltdb/entfernen.png" );
  27. close->setHintergrundBildZ( closeBild );
  28. initToolTip( close, "Nachricht ignorieren." );
  29. maxHöhe = 20;
  30. animation = 1;
  31. ausgewählt = 0;
  32. tickVal = 0;
  33. rend = 0;
  34. höhe = 0;
  35. }
  36. NLNachricht::~NLNachricht()
  37. {
  38. titel = (TextFeld *)titel->release();
  39. close = (Knopf *)close->release();
  40. rahmen->release();
  41. }
  42. void NLNachricht::entfernen()
  43. {
  44. animation = 3;
  45. }
  46. void NLNachricht::setAusgewählt( bool ausgewählt )
  47. {
  48. if( animation != 3 )
  49. {
  50. this->ausgewählt = ausgewählt;
  51. if( ausgewählt )
  52. animation = 2;
  53. else
  54. animation = 1;
  55. }
  56. }
  57. void NLNachricht::doPublicMausEreignis( MausEreignis &me )
  58. {
  59. if( animation != 3 )
  60. {
  61. bool tmp = 0;
  62. if( me.my > höhe || !ausgewählt )
  63. {
  64. tmp = me.verarbeitet;
  65. me.verarbeitet = 1;
  66. }
  67. char aktion = me.verarbeitet ? 2 : 0;
  68. close->doPublicMausEreignis( me );
  69. if( !aktion )
  70. aktion = me.verarbeitet ? 1 : 0;
  71. if( me.my > höhe || !ausgewählt )
  72. {
  73. me.verarbeitet = tmp;
  74. return;
  75. }
  76. if( me.id != ME_RLinks )
  77. return;
  78. if( aktion == 1 )
  79. entfernen();
  80. }
  81. }
  82. bool NLNachricht::tick( double tickVal )
  83. {
  84. rend |= close->tick( tickVal );
  85. if( !animation )
  86. {
  87. bool ret = rend;
  88. rend = 0;
  89. return ret;
  90. }
  91. this->tickVal += tickVal * 100;
  92. int val = (int)this->tickVal;
  93. if( val < 1 )
  94. {
  95. bool ret = rend;
  96. rend = 0;
  97. return ret;
  98. }
  99. if( val > 4 )
  100. val = 4;
  101. this->tickVal -= val;
  102. switch( animation )
  103. {
  104. case 1:
  105. if( höhe != 20 )
  106. {
  107. if( höhe > 20 )
  108. {
  109. höhe -= val;
  110. if( höhe < 20 )
  111. höhe = 20;
  112. }
  113. else
  114. {
  115. höhe += val;
  116. if( höhe > 20 )
  117. höhe = 20;
  118. }
  119. rend = 1;
  120. }
  121. else
  122. animation = 0;
  123. break;
  124. case 2:
  125. if( höhe != maxHöhe )
  126. {
  127. höhe += val;
  128. if( höhe > maxHöhe )
  129. höhe = maxHöhe;
  130. rend = 1;
  131. }
  132. else
  133. animation = 0;
  134. break;
  135. case 3:
  136. höhe -= val;
  137. if( höhe <= 0 )
  138. {
  139. nachLogin->zNachrichtenListe()->removeNachricht( this ); // delete this
  140. return 1;
  141. }
  142. rend = 1;
  143. break;
  144. }
  145. bool ret = rend;
  146. rend = 0;
  147. return ret;
  148. }
  149. void NLNachricht::render( int y, Bild &zRObj )
  150. {
  151. int br = 228;
  152. int hö = höhe;
  153. if( !zRObj.setDrawOptions( 0, y, br, hö ) )
  154. return;
  155. rahmen->setSize( br, hö );
  156. rahmen->render( zRObj );
  157. int rbr = rahmen->getRBreite();
  158. if( !zRObj.setDrawOptions( rbr, rbr, br - rbr * 2, hö - rbr * 2 ) )
  159. {
  160. zRObj.releaseDrawOptions();
  161. return;
  162. }
  163. titel->render( zRObj );
  164. close->render( zRObj );
  165. zRObj.releaseDrawOptions();
  166. zRObj.releaseDrawOptions();
  167. }
  168. // contant
  169. bool NLNachricht::istAusgewählt() const
  170. {
  171. return ausgewählt;
  172. }
  173. int NLNachricht::getHeight() const
  174. {
  175. return höhe;
  176. }
  177. Text *NLNachricht::zTitel() const
  178. {
  179. return titel->zText();
  180. }
  181. SpielUpdateNachricht::SpielUpdateNachricht( Text *titel, Text *nachricht, int dgID, std::function<void()> posAk, std::function<void()> negAk )
  182. : NLNachricht( titel )
  183. {
  184. Text *result = new Text( nachricht->getText() );
  185. int län = nachricht->getLength();
  186. char *txt = nachricht->getText();
  187. int x = 0;
  188. int y = 0;
  189. Alphabet *tmp = uiFactory.initParam.schrift->getAlphabet( 12 );
  190. TextRenderer rd( dynamic_cast<Schrift *>( uiFactory.initParam.schrift->getThis() ) );
  191. rd.setSchriftSize( 12 );
  192. int zeilenHöhe = rd.getZeilenHeight() + rd.getZeilenAbstand();
  193. int lastPos = -1;
  194. for( int i = 0; i < län; i++ )
  195. {
  196. char c = txt[ i ];
  197. if( c == ' ' )
  198. {
  199. lastPos = i;
  200. x += 6;
  201. continue;
  202. }
  203. if( c == '\n' )
  204. {
  205. x = 0;
  206. y += zeilenHöhe;
  207. lastPos = -1;
  208. continue;
  209. }
  210. Buchstabe *b = tmp->getBuchstabe( (unsigned)c );
  211. if( b )
  212. {
  213. x += b->getBreite();
  214. if( x > 228 && lastPos > -1 )
  215. {
  216. result->ersetzen( lastPos, lastPos + 1, "\n" );
  217. x = 0;
  218. y += zeilenHöhe;
  219. i = lastPos;
  220. lastPos = -1;
  221. }
  222. b->release();
  223. }
  224. }
  225. y += zeilenHöhe;
  226. tmp->release();
  227. nachricht->release();
  228. text = initTextFeld( 1, 22, 228, y, TextFeld::Style::Text, result->getText() );
  229. result->release();
  230. fortschritt = initFBalken( 5, y + 20, 215, 20, FBalken::Style::normal );
  231. herunterladen = initKnopf( 10, 45 + y, 120, 20, Knopf::Style::Sichtbar, "herunterladen" );
  232. abbrechen = initKnopf( 140, 45 + y, 80, 20, Knopf::Style::Sichtbar, "abbrechen" );
  233. this->posAk = posAk;
  234. this->negAk = negAk;
  235. maxHöhe = 75 + y;
  236. update = new Update( dynamic_cast<FBalken *>( fortschritt->getThis() ), dgID, [this]( bool ok )
  237. {
  238. this->animation = 3;
  239. if( ok )
  240. this->posAk();
  241. else
  242. this->negAk();
  243. } );
  244. if( !updateH->add( dynamic_cast<Update *>( update->getThis() ) ) )
  245. entfernen();
  246. }
  247. SpielUpdateNachricht::~SpielUpdateNachricht()
  248. {
  249. text->release();
  250. herunterladen->release();
  251. abbrechen->release();
  252. fortschritt->release();
  253. updateH->remove( update->getDateiGruppe() );
  254. update->abbrechen();
  255. update->warteAufThread( 10000 );
  256. update->ende();
  257. update->release();
  258. }
  259. // nicht constant
  260. void SpielUpdateNachricht::entfernen()
  261. {
  262. __super::entfernen();
  263. negAk();
  264. }
  265. void SpielUpdateNachricht::doPublicMausEreignis( MausEreignis &me )
  266. {
  267. __super::doPublicMausEreignis( me );
  268. if( animation != 3 )
  269. {
  270. bool tmp = 0;
  271. if( me.my > höhe || !ausgewählt )
  272. {
  273. tmp = me.verarbeitet;
  274. me.verarbeitet = 1;
  275. }
  276. char aktion = me.verarbeitet ? 3 : 0;
  277. herunterladen->doPublicMausEreignis( me );
  278. if( !aktion )
  279. aktion = me.verarbeitet ? 1 : 0;
  280. abbrechen->doPublicMausEreignis( me );
  281. if( !aktion )
  282. aktion = me.verarbeitet ? 2 : 0;
  283. if( me.my > höhe || !ausgewählt )
  284. {
  285. me.verarbeitet = tmp;
  286. return;
  287. }
  288. if( me.id != ME_RLinks )
  289. return;
  290. switch( aktion )
  291. {
  292. case 1:
  293. // positiv
  294. update->herunterladen();
  295. herunterladen->removeStyle( Knopf::Style::Erlaubt | Knopf::Style::Sichtbar );
  296. break;
  297. case 2:
  298. // negativ
  299. update->abbrechen();
  300. abbrechen->removeStyle( Knopf::Style::Erlaubt | Knopf::Style::Sichtbar );
  301. break;
  302. }
  303. }
  304. }
  305. bool SpielUpdateNachricht::tick( double tickVal )
  306. {
  307. rend |= herunterladen->tick( tickVal );
  308. rend |= fortschritt->tick( tickVal );
  309. rend |= abbrechen->tick( tickVal );
  310. rend |= text->tick( tickVal );
  311. return __super::tick( tickVal );
  312. }
  313. void SpielUpdateNachricht::render( int y, Bild &zRObj )
  314. {
  315. __super::render( y, zRObj );
  316. int rbr = rahmen->getRBreite();
  317. if( !zRObj.setDrawOptions( rbr, y + rbr, rahmen->getBreite() - rbr * 2, rahmen->getHeight() - rbr * 2 ) )
  318. return;
  319. text->render( zRObj );
  320. fortschritt->render( zRObj );
  321. herunterladen->render( zRObj );
  322. abbrechen->render( zRObj );
  323. zRObj.releaseDrawOptions();
  324. }
  325. // Inhalt der Nachricht Klasse aus NachrichtListe.h
  326. // Konstruktor
  327. Nachricht::Nachricht( Text *titel, Text *nachricht, Text *positiv, Text *negativ, std::function<void()> posAk, std::function<void()> negAk )
  328. : NLNachricht( titel )
  329. {
  330. Text *result = new Text( nachricht->getText() );
  331. int län = nachricht->getLength();
  332. char *txt = nachricht->getText();
  333. int x = 0;
  334. int y = 0;
  335. Alphabet *tmp = uiFactory.initParam.schrift->getAlphabet( 12 );
  336. TextRenderer rd( dynamic_cast<Schrift *>( uiFactory.initParam.schrift->getThis() ) );
  337. rd.setSchriftSize( 12 );
  338. int zeilenHöhe = rd.getZeilenHeight() + rd.getZeilenAbstand();
  339. int lastPos = -1;
  340. for( int i = 0; i < län; i++ )
  341. {
  342. char c = txt[ i ];
  343. if( c == ' ' )
  344. {
  345. lastPos = i;
  346. x += 6;
  347. continue;
  348. }
  349. if( c == '\n' )
  350. {
  351. x = 0;
  352. y += zeilenHöhe;
  353. lastPos = -1;
  354. continue;
  355. }
  356. Buchstabe *b = tmp->getBuchstabe( (unsigned)c );
  357. if( b )
  358. {
  359. x += b->getBreite();
  360. if( x > 228 && lastPos > -1 )
  361. {
  362. result->ersetzen( lastPos, lastPos + 1, "\n" );
  363. x = 0;
  364. y += zeilenHöhe;
  365. i = lastPos;
  366. lastPos = -1;
  367. }
  368. b->release();
  369. }
  370. }
  371. y += zeilenHöhe;
  372. tmp->release();
  373. nachricht->release();
  374. text = initTextFeld( 1, 22, 228, y, TextFeld::Style::Text, result->getText() );
  375. result->release();
  376. if( positiv )
  377. {
  378. this->positiv = initKnopf( 10, 20 + y, 100, 20, Knopf::Style::Sichtbar, positiv->getText() );
  379. positiv->release();
  380. }
  381. else
  382. this->positiv = 0;
  383. if( negativ )
  384. {
  385. this->negativ = initKnopf( 120, 20 + y, 100, 20, Knopf::Style::Sichtbar, negativ->getText() );
  386. negativ->release();
  387. }
  388. else
  389. this->negativ = 0;
  390. this->posAk = posAk;
  391. this->negAk = negAk;
  392. maxHöhe = 50 + y;
  393. }
  394. // Destruktor
  395. Nachricht::~Nachricht()
  396. {
  397. text = (TextFeld *)text->release();
  398. if( positiv )
  399. positiv = (Knopf *)positiv->release();
  400. if( negativ )
  401. negativ = (Knopf *)negativ->release();
  402. }
  403. void Nachricht::entfernen()
  404. {
  405. __super::entfernen();
  406. negAk();
  407. }
  408. void Nachricht::doPublicMausEreignis( MausEreignis &me )
  409. {
  410. __super::doPublicMausEreignis( me );
  411. if( animation != 3 )
  412. {
  413. bool tmp = 0;
  414. if( me.my > höhe || !ausgewählt )
  415. {
  416. tmp = me.verarbeitet;
  417. me.verarbeitet = 1;
  418. }
  419. char aktion = me.verarbeitet ? 3 : 0;
  420. if( positiv )
  421. positiv->doPublicMausEreignis( me );
  422. if( !aktion )
  423. aktion = me.verarbeitet ? 1 : 0;
  424. if( negativ )
  425. negativ->doPublicMausEreignis( me );
  426. if( !aktion )
  427. aktion = me.verarbeitet ? 2 : 0;
  428. if( me.my > höhe || !ausgewählt )
  429. {
  430. me.verarbeitet = tmp;
  431. return;
  432. }
  433. if( me.id != ME_RLinks )
  434. return;
  435. switch( aktion )
  436. {
  437. case 1:
  438. // positiv
  439. __super::entfernen();
  440. posAk();
  441. break;
  442. case 2:
  443. // negativ
  444. __super::entfernen();
  445. negAk();
  446. break;
  447. }
  448. }
  449. }
  450. bool Nachricht::tick( double tickVal )
  451. {
  452. rend |= positiv ? positiv->tick( tickVal ) : 0;
  453. rend |= negativ ? negativ->tick( tickVal ) : 0;
  454. rend |= text->tick( tickVal );
  455. return __super::tick( tickVal );
  456. }
  457. void Nachricht::render( int yPos, Bild &zRObj )
  458. {
  459. __super::render( yPos, zRObj );
  460. int rbr = rahmen->getRBreite();
  461. if( !zRObj.setDrawOptions( rbr, yPos + rbr, rahmen->getBreite() - rbr * 2, rahmen->getHeight() - rbr * 2 ) )
  462. return;
  463. text->render( zRObj );
  464. if( positiv )
  465. positiv->render( zRObj );
  466. if( negativ )
  467. negativ->render( zRObj );
  468. zRObj.releaseDrawOptions();
  469. }
  470. // Inhalt der NachrichtenListeObj Klasse aus NachrichtListe.h
  471. // Konstruktor
  472. NachrichtenListeObj::NachrichtenListeObj()
  473. : Zeichnung()
  474. {
  475. members = new RCArray< NLNachricht >();
  476. vsb = new VScrollBar();
  477. vsb->setKlickScroll( 10 );
  478. bildschirmGröße = uiFactory.initParam.bildschirm->getBackBufferSize();
  479. vsb->update( 0, bildschirmGröße.y - 122 );
  480. anzahl = 0;
  481. gr = Punkt( 250, bildschirmGröße.y - 122 );
  482. }
  483. // Destruktor
  484. NachrichtenListeObj::~NachrichtenListeObj()
  485. {
  486. vsb = (VScrollBar *)vsb->release();
  487. members->release();
  488. }
  489. // nicht constant
  490. void NachrichtenListeObj::addNachricht( NLNachricht *nachricht )
  491. {
  492. members->add( nachricht, anzahl );
  493. anzahl++;
  494. rend = 1;
  495. }
  496. void NachrichtenListeObj::removeNachricht( NLNachricht *zNachricht )
  497. {
  498. for( int i = 0; i < anzahl; i++ )
  499. {
  500. if( members->z( i ) == zNachricht )
  501. {
  502. members->remove( i );
  503. anzahl--;
  504. rend = 1;
  505. break;
  506. }
  507. }
  508. }
  509. void NachrichtenListeObj::removeAll()
  510. {
  511. lockZeichnung();
  512. members->leeren();
  513. anzahl = 0;
  514. rend = 1;
  515. unlockZeichnung();
  516. }
  517. bool NachrichtenListeObj::tick( double tickVal )
  518. {
  519. lockZeichnung();
  520. rend |= vsb->getRend();
  521. rend |= nachLogin->zNachrichtenListe()->tick( tickVal );
  522. for( int i = 0; i < anzahl; i++ )
  523. {
  524. NLNachricht *tmp = members->z( i );
  525. if( tmp )
  526. rend |= tmp->tick( tickVal );
  527. }
  528. unlockZeichnung();
  529. bool ret = rend;
  530. rend = 0;
  531. return ret;
  532. }
  533. void NachrichtenListeObj::doPublicMausEreignis( MausEreignis &me )
  534. {
  535. lockZeichnung();
  536. int my = me.my;
  537. me.my -= 20;
  538. if( me.mx <= 229 && me.mx > 0 && me.my >= 0 )
  539. {
  540. me.my += vsb->getScroll();
  541. for( int i = 0; i < anzahl; i++ )
  542. {
  543. NLNachricht *tmp = members->z( i );
  544. if( tmp )
  545. {
  546. if( me.my > 0 && me.my < tmp->getHeight() )
  547. tmp->setAusgewählt( 1 );
  548. else
  549. tmp->setAusgewählt( 0 );
  550. tmp->doPublicMausEreignis( me );
  551. me.my -= tmp->getHeight();
  552. }
  553. }
  554. me.my -= vsb->getScroll();
  555. }
  556. else
  557. {
  558. me.my += vsb->getScroll();
  559. for( int i = 0; i < anzahl; i++ )
  560. {
  561. NLNachricht *tmp = members->z( i );
  562. if( tmp )
  563. {
  564. tmp->setAusgewählt( 0 );
  565. tmp->doPublicMausEreignis( me );
  566. me.my -= tmp->getHeight();
  567. }
  568. }
  569. me.my -= vsb->getScroll();
  570. }
  571. me.my = my;
  572. vsb->doMausMessage( 229, 20, 20, bildschirmGröße.y - 122, me );
  573. unlockZeichnung();
  574. }
  575. void NachrichtenListeObj::render( Bild &zrObj )
  576. {
  577. lockZeichnung();
  578. int x = pos.x;
  579. int y = pos.y;
  580. int br = gr.x;
  581. int hö = gr.y;
  582. if( !zrObj.setDrawOptions( x, y, br, hö ) )
  583. {
  584. unlockZeichnung();
  585. return;
  586. }
  587. int höhe = 0;
  588. for( int i = 0; i < anzahl; i++ )
  589. {
  590. NLNachricht *tmp = members->z( i );
  591. tmp->render( höhe - ( vsb ? vsb->getScroll() : 0 ), zrObj );
  592. höhe += tmp->getHeight();
  593. }
  594. if( vsb )
  595. {
  596. vsb->update( höhe, bildschirmGröße.y - 122 );
  597. vsb->render( 229, 0, 20, bildschirmGröße.y - 122, zrObj );
  598. }
  599. zrObj.releaseDrawOptions();
  600. unlockZeichnung();
  601. }
  602. // Inhalt der NachrichtenListe Klasse aus NachrichtListe.h
  603. // Konstruktor
  604. NachrichtenListe::NachrichtenListe( Fenster *zNachLoginFenster )
  605. : ReferenceCounter()
  606. {
  607. minimierenBild = bilder->get( "data/client/bilder/chat.ltdb/minimieren.png" );
  608. maximierenBild = bilder->get( "data/client/bilder/chat.ltdb/maximieren.png" );
  609. bildschirmGröße = uiFactory.initParam.bildschirm->getBackBufferSize();
  610. fenster = initFenster( bildschirmGröße.x - 21, 100, 250, 22, Fenster::Style::Sichtbar | Fenster::Style::Erlaubt | Fenster::Style::Rahmen | Fenster::Style::BodyHintergrund, "" );
  611. fenster->setKBgFarbe( 0xFF000000 );
  612. überschrift = initTextFeld( 1, 1, 248, 20, TextFeld::Style::Text | TextFeld::Style::Center | TextFeld::Style::Sichtbar, "Nachrichten" );
  613. überschrift->setSchriftSize( 15 );
  614. fenster->addMember( dynamic_cast<Zeichnung *>( überschrift->getThis() ) );
  615. minMax = initKnopf( 1, 1, 20, 20, 0, "" );
  616. minMax->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HBild | Knopf::Style::HAlpha | Knopf::Style::KlickBuffer );
  617. minMax->setMausEreignisParameter( this );
  618. minMax->setMausEreignis( NachrichtenListeMinMaxME );
  619. minMax->setHintergrundBildZ( dynamic_cast<Bild *>( minimierenBild->getThis() ) );
  620. initToolTip( minMax, "Nachrichten Leiste minimieren." );
  621. fenster->addMember( dynamic_cast<Zeichnung *>( minMax->getThis() ) );
  622. nachrichtenListe = new NachrichtenListeObj();
  623. nachrichtenListe->setPosition( 1, 21 );
  624. nachrichtenListe->setSize( 248, bildschirmGröße.y - 122 );
  625. fenster->addMember( dynamic_cast<Zeichnung *>( nachrichtenListe->getThis() ) );
  626. zNachLoginFenster->addMember( dynamic_cast<Zeichnung *>( fenster->getThis() ) );
  627. tickVal = 0;
  628. animation = 1;
  629. rend = 0;
  630. msgSound = 0;
  631. errSound = 0;
  632. HMODULE dll = Framework::getDLLRegister()->ladeDLL( "GSL.dll", "data/bin/GSL.dll" );
  633. if( dll )
  634. {
  635. GetGSLDatei getGSLDatei = (GetGSLDatei)GetProcAddress( dll, "getGSLDatei" );
  636. if( getGSLDatei )
  637. {
  638. GSL::GSLDateiV *sDat = getGSLDatei();
  639. sDat->setDatei( "data/sounds/popup.gsl" );
  640. sDat->leseDaten();
  641. msgSound = sDat->getSound( "info.wav" );
  642. errSound = sDat->getSound( "error.wav" );
  643. sDat->release();
  644. if( msgSound )
  645. msgSound->setVolume( 0xFFFF, 0xFFFF );
  646. if( errSound )
  647. errSound->setVolume( 0xFFFF, 0xFFFF );
  648. }
  649. if( !msgSound && !errSound )
  650. Framework::getDLLRegister()->releaseDLL( "GSL.dll" );
  651. }
  652. }
  653. // Destruktor
  654. NachrichtenListe::~NachrichtenListe()
  655. {
  656. if( msgSound || errSound )
  657. {
  658. if( msgSound )
  659. {
  660. msgSound->stopSound();
  661. msgSound->release();
  662. }
  663. if( errSound )
  664. {
  665. errSound->stopSound();
  666. errSound->release();
  667. }
  668. Framework::getDLLRegister()->releaseDLL( "GSL.dll" );
  669. }
  670. überschrift = (TextFeld *)überschrift->release();
  671. fenster = (Fenster *)fenster->release();
  672. minMax = (Knopf *)minMax->release();
  673. nachrichtenListe = (NachrichtenListeObj *)nachrichtenListe->release();
  674. minimierenBild->release();
  675. maximierenBild->release();
  676. schrift->release();
  677. }
  678. // nicht constant
  679. void NachrichtenListe::addNachricht( Text *titel, Text *nachricht, Text *positiv, Text *negativ, std::function<void()> posAk, std::function<void()> negAk )
  680. {
  681. int sound = userOptions->wertExistiert( "GUISound" ) ? *userOptions->zWert( "GUISound" ) : 100;
  682. if( titel && titel->hat( "Fehler" ) && errSound )
  683. {
  684. errSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
  685. errSound->playSound();
  686. }
  687. else if( msgSound )
  688. {
  689. msgSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
  690. msgSound->playSound();
  691. }
  692. nachrichtenListe->addNachricht( new Nachricht( titel, nachricht, positiv, negativ, posAk, negAk ) );
  693. }
  694. void NachrichtenListe::addNachricht( NLNachricht *nachricht )
  695. {
  696. int sound = userOptions->wertExistiert( "GUISound" ) ? *userOptions->zWert( "GUISound" ) : 100;
  697. if( nachricht->zTitel() && nachricht->zTitel()->hat( "Fehler" ) && errSound )
  698. {
  699. errSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
  700. errSound->playSound();
  701. }
  702. else if( msgSound )
  703. {
  704. msgSound->setVolume( (int)( ( sound / 100.0 ) * 0xFFFF ), (int)( ( sound / 100.0 ) * 0xFFFF ) );
  705. msgSound->playSound();
  706. }
  707. nachrichtenListe->addNachricht( nachricht );
  708. }
  709. void NachrichtenListe::removeNachricht( NLNachricht *zNachricht )
  710. {
  711. nachrichtenListe->removeNachricht( zNachricht );
  712. }
  713. void NachrichtenListe::removeAll()
  714. {
  715. nachrichtenListe->removeAll();
  716. }
  717. bool NachrichtenListe::druckMinMax( MausEreignis &me )
  718. {
  719. if( me.id == ME_RLinks )
  720. {
  721. if( minMax->zHintergrundBild() == minimierenBild )
  722. {
  723. animation = 2;
  724. minMax->setHintergrundBildZ( dynamic_cast<Bild *>( maximierenBild->getThis() ) );
  725. // TODO minMax->zToolTip()->setText( "Nachrichten Leiste maximieren." );
  726. }
  727. else
  728. {
  729. animation = 1;
  730. minMax->setHintergrundBildZ( dynamic_cast<Bild *>( minimierenBild->getThis() ) );
  731. // TODO minMax->zToolTip()->setText( "Nachrichten Leiste minimieren." );
  732. }
  733. }
  734. return 1;
  735. }
  736. bool NachrichtenListe::tick( double tickVal )
  737. {
  738. if( !animation )
  739. {
  740. bool ret = rend;
  741. rend = 0;
  742. return ret;
  743. }
  744. this->tickVal += tickVal * 400;
  745. int val = (int)this->tickVal;
  746. if( val < 1 )
  747. {
  748. bool ret = rend;
  749. rend = 0;
  750. return ret;
  751. }
  752. if( val > 14 )
  753. val = 14;
  754. this->tickVal -= val;
  755. switch( animation )
  756. {
  757. case 1: // maximieren
  758. if( fenster->getX() > bildschirmGröße.x - 250 )
  759. {
  760. fenster->setPosition( fenster->getX() - val, fenster->getY() );
  761. minMax->setPosition( minMax->getX() + val, minMax->getY() );
  762. if( fenster->getX() < bildschirmGröße.x - 250 )
  763. {
  764. fenster->setPosition( bildschirmGröße.x - 250, fenster->getY() );
  765. minMax->setPosition( 229, minMax->getY() );
  766. }
  767. rend = 1;
  768. }
  769. else if( fenster->getHeight() < bildschirmGröße.y - 100 )
  770. {
  771. fenster->setSize( fenster->getBreite(), fenster->getHeight() + val );
  772. if( fenster->getHeight() >= bildschirmGröße.y - 100 )
  773. {
  774. fenster->setSize( fenster->getBreite(), bildschirmGröße.y - 100 );
  775. animation = 0;
  776. }
  777. rend = 1;
  778. }
  779. break;
  780. case 2: // minimieren
  781. if( fenster->getHeight() > 22 )
  782. {
  783. fenster->setSize( fenster->getBreite(), fenster->getHeight() - val );
  784. if( fenster->getHeight() < 22 )
  785. fenster->setSize( fenster->getBreite(), 22 );
  786. rend = 1;
  787. }
  788. else if( fenster->getX() < bildschirmGröße.x - 21 )
  789. {
  790. minMax->setPosition( minMax->getX() - val, minMax->getY() );
  791. fenster->setPosition( fenster->getX() + val, fenster->getY() );
  792. if( fenster->getX() >= bildschirmGröße.x - 21 )
  793. {
  794. minMax->setPosition( 1, minMax->getY() );
  795. fenster->setPosition( bildschirmGröße.x - 21, fenster->getY() );
  796. animation = 0;
  797. }
  798. rend = 1;
  799. }
  800. break;
  801. }
  802. bool ret = rend;
  803. rend = 0;
  804. return ret;
  805. }
  806. // Nachrichten
  807. bool NachrichtenListeMinMaxME( void *p, void *obj, MausEreignis me )
  808. {
  809. return ( (NachrichtenListe *)p )->druckMinMax( me );
  810. }