NachrichtenListe.cpp 21 KB

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