AccountSpieleUndKarten.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. #include "AccountSpieleUndKarten.h"
  2. #include "../../../Global/Initialisierung.h"
  3. #include "../../../Global/Variablen.h"
  4. #include <Rahmen.h>
  5. #include <DateiSystem.h>
  6. #include <Punkt.h>
  7. #include <ToolTip.h>
  8. #include <AuswahlBox.h>
  9. // Inhalt der AccountSUKListeKarte Klasse aus AccountSpieleUndKarten.h
  10. // Konstruktor
  11. AccountSUKListeKarte::AccountSUKListeKarte( int id, int account )
  12. : ReferenceCounter(),
  13. ram( new LRahmen() ),
  14. name( initTextFeld( 5, 0, 150, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Karte: " ) ),
  15. spiele( initTextFeld( 165, 0, 150, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Spiele: " ) ),
  16. gewonnen( initTextFeld( 325, 0, 150, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Gewonnen: " ) ),
  17. status( initTextFeld( 485, 0, 150, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Status: " ) ),
  18. st( new Text() ),
  19. karteId( id ),
  20. rend( 0 )
  21. {
  22. na = infoClient->getKarteName( id );
  23. if( na )
  24. name->zText()->append( na->getText() );
  25. sp = infoClient->getAccountKarteSpiele( account, id );
  26. spiele->zText()->append( sp );
  27. gw = infoClient->getAccountKarteSpieleGewonnen( account, id );
  28. gewonnen->zText()->append( gw );
  29. if( infoClient->hatAccountKarte( account, id ) )
  30. st->setText( "Im Besitz" );
  31. else
  32. st->setText( "Nicht im Besitz" );
  33. status->zText()->append( st->getText() );
  34. ram->setFarbe( 0xFFFFFFFF );
  35. ram->setSize( 715, 20 );
  36. ram->setRamenBreite( 1 );
  37. }
  38. // Destruktor
  39. AccountSUKListeKarte::~AccountSUKListeKarte()
  40. {
  41. ram->release();
  42. name->release();
  43. spiele->release();
  44. gewonnen->release();
  45. status->release();
  46. if( na )
  47. na->release();
  48. st->release();
  49. }
  50. // nicht constant
  51. void AccountSUKListeKarte::render( int yOff, Bild &zRObj )
  52. {
  53. if( !zRObj.setDrawOptions( 5, yOff, ram->getBreite(), ram->getHeight() ) )
  54. return;
  55. name->render( zRObj );
  56. spiele->render( zRObj );
  57. gewonnen->render( zRObj );
  58. status->render( zRObj );
  59. ram->render( zRObj );
  60. zRObj.releaseDrawOptions();
  61. }
  62. // constant
  63. Text *AccountSUKListeKarte::zName() const
  64. {
  65. return na;
  66. }
  67. int AccountSUKListeKarte::getSpiele() const
  68. {
  69. return sp;
  70. }
  71. int AccountSUKListeKarte::getGewonnen() const
  72. {
  73. return gw;
  74. }
  75. Text *AccountSUKListeKarte::zStatus() const
  76. {
  77. return st;
  78. }
  79. // Inhalt der AccountSUKListeSpiel Klasse aus AccountSpieleUndKarten.h
  80. // Konstruktor
  81. AccountSUKListeSpiel::AccountSUKListeSpiel( int id, int account )
  82. : ReferenceCounter(),
  83. ram( new LRahmen() ),
  84. nameTF( initTextFeld( 5, 0, 150, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Name: " ) ),
  85. spieleTF( initTextFeld( 165, 0, 150, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Spiele: " ) ),
  86. gewonnenTF( initTextFeld( 325, 0, 100, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Gewonnen: " ) ),
  87. punkteTF( initTextFeld( 435, 0, 100, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Punkte: " ) ),
  88. statusTF( initTextFeld( 545, 0, 150, 20, TextFeld::Style::Text | TextFeld::Style::Center, "Status: " ) ),
  89. details( initKnopf( 705, 0, 20, 20, 0, "" ) ),
  90. karten( new RCArray< AccountSUKListeKarte >() ),
  91. einklappen( bilder->get( "data/client/bilder/account.ltdb/einklappen.png" ) ),
  92. ausklappen( bilder->get( "data/client/bilder/account.ltdb/ausklappen.png" ) ),
  93. status( new Text() ),
  94. statusFilter( new Text( "Alle" ) ),
  95. sortSpalte( new Text( "Name" ) ),
  96. sortAbsteigend( 0 ),
  97. spielId( id ),
  98. tickVal( 0 ),
  99. rend( 0 )
  100. {
  101. ram->setFarbe( 0xFFFFFFFF );
  102. ram->setRamenBreite( 1 );
  103. ram->setSize( 725, 20 );
  104. details->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  105. details->setHintergrundBildZ( dynamic_cast<Bild *>( ausklappen->getThis() ) );
  106. initToolTip( details, "Karten anzeigen." );
  107. name = infoClient->getSpielName( id );
  108. if( name )
  109. nameTF->zText()->append( name->getText() );
  110. Array< int > *stat = new Array< int >();
  111. if( infoClient->getSpielStatistik( account, id, stat ) )
  112. {
  113. spiele = stat->get( 0 );
  114. gewonnen = stat->get( 1 );
  115. punkte = stat->get( 3 );
  116. }
  117. stat->release();
  118. spieleTF->zText()->append( spiele );
  119. gewonnenTF->zText()->append( gewonnen );
  120. punkteTF->zText()->append( punkte );
  121. if( infoClient->hatAccountSpiel( account, id ) )
  122. status->setText( "Im Besitz" );
  123. else
  124. status->setText( "Nicht im Besitz" );
  125. statusTF->zText()->append( status->getText() );
  126. Array< int > *maps = infoClient->getAccountKarteGespieltListe( account, id );
  127. if( maps )
  128. {
  129. int anz = maps->getEintragAnzahl();
  130. for( int i = 0; i < anz; i++ )
  131. karten->set( new AccountSUKListeKarte( maps->get( i ), account ), i );
  132. maps->release();
  133. }
  134. }
  135. // Destruktor
  136. AccountSUKListeSpiel::~AccountSUKListeSpiel()
  137. {
  138. ram->release();
  139. nameTF->release();
  140. spieleTF->release();
  141. gewonnenTF->release();
  142. punkteTF->release();
  143. statusTF->release();
  144. details->release();
  145. karten->release();
  146. einklappen->release();
  147. ausklappen->release();
  148. if( name )
  149. name->release();
  150. status->release();
  151. statusFilter->release();
  152. sortSpalte->release();
  153. }
  154. // privat
  155. int AccountSUKListeSpiel::getReihenfolge( int *arr )
  156. {
  157. int anz = karten->getEintragAnzahl();
  158. if( !anz )
  159. return 0;
  160. int ret = 0;
  161. bool *fertig = new bool[ anz ];
  162. ZeroMemory( fertig, anz );
  163. for( int i = 0; i < anz; i++ )
  164. {
  165. int index = -1;
  166. int minMax = 0;
  167. Text minMaxT;
  168. for( int j = 0; j < anz; j++ )
  169. {
  170. AccountSUKListeKarte *tmp = karten->z( j );
  171. if( !statusFilter->istGleich( "Alle" ) && !tmp->zStatus()->istGleich( statusFilter->getText() ) )
  172. continue;
  173. if( sortSpalte->istGleich( "Name" ) && !fertig[ j ] && ( index < 0 ||
  174. ( sortAbsteigend && *tmp->zName() > minMaxT ) || ( !sortAbsteigend && *tmp->zName() < minMaxT ) ) )
  175. {
  176. minMaxT = tmp->zName()->getText();
  177. index = j;
  178. }
  179. else if( sortSpalte->istGleich( "Spiele" ) && !fertig[ j ] && ( index < 0 ||
  180. ( sortAbsteigend && tmp->getSpiele() > minMax ) || ( !sortAbsteigend && tmp->getSpiele() < minMax ) ) )
  181. {
  182. minMax = tmp->getSpiele();
  183. index = j;
  184. }
  185. else if( sortSpalte->istGleich( "Gewonnen" ) && !fertig[ j ] && ( index < 0 ||
  186. ( sortAbsteigend && tmp->getGewonnen() > minMax ) || ( !sortAbsteigend && tmp->getGewonnen() < minMax ) ) )
  187. {
  188. minMax = tmp->getGewonnen();
  189. index = j;
  190. }
  191. else if( sortSpalte->istGleich( "Status" ) && !fertig[ j ] && ( index < 0 ||
  192. ( sortAbsteigend && *tmp->zStatus() > minMaxT ) || ( !sortAbsteigend && *tmp->zStatus() < minMaxT ) ) )
  193. {
  194. minMaxT = tmp->zStatus()->getText();
  195. index = j;
  196. }
  197. else if( sortSpalte->istGleich( "Punkte" ) && !fertig[ j ] )
  198. {
  199. index = j;
  200. break;
  201. }
  202. }
  203. if( index < 0 )
  204. break;
  205. fertig[ index ] = 1;
  206. arr[ ret ] = index;
  207. ret++;
  208. }
  209. delete[] fertig;
  210. return ret;
  211. }
  212. // nicht constant
  213. void AccountSUKListeSpiel::setStatusAusw( char *status )
  214. {
  215. statusFilter->setText( status );
  216. rend = 1;
  217. }
  218. void AccountSUKListeSpiel::setSortSpalte( char *spalte )
  219. {
  220. sortSpalte->setText( spalte );
  221. rend = 1;
  222. }
  223. void AccountSUKListeSpiel::setSortRichtung( bool absteigend )
  224. {
  225. sortAbsteigend = absteigend;
  226. rend = 1;
  227. }
  228. bool AccountSUKListeSpiel::tick( double tickVal )
  229. {
  230. rend |= details->tick( tickVal );
  231. this->tickVal += tickVal * 150;
  232. int val = (int)this->tickVal;
  233. this->tickVal -= val;
  234. if( val )
  235. {
  236. if( details->zHintergrundBild() == ausklappen && ram->getHeight() != 20 )
  237. {
  238. if( ram->getHeight() - val < 20 )
  239. ram->setSize( ram->getBreite(), 20 );
  240. else
  241. ram->setSize( ram->getBreite(), ram->getHeight() - val );
  242. rend = 1;
  243. }
  244. if( details->zHintergrundBild() == einklappen )
  245. {
  246. int maxHö = 20;
  247. int anz = karten->getEintragAnzahl();
  248. for( int i = 0; i < anz; i++ )
  249. {
  250. AccountSUKListeKarte *tmp = karten->z( i );
  251. if( !statusFilter->istGleich( "Alle" ) && !tmp->zStatus()->istGleich( statusFilter->getText() ) )
  252. continue;
  253. maxHö += 25;
  254. }
  255. if( maxHö > 20 )
  256. maxHö += 5;
  257. if( ram->getHeight() > maxHö )
  258. {
  259. if( ram->getHeight() - val < maxHö )
  260. ram->setSize( ram->getBreite(), maxHö );
  261. else
  262. ram->setSize( ram->getBreite(), ram->getHeight() - val );
  263. rend = 1;
  264. }
  265. if( ram->getHeight() < maxHö )
  266. {
  267. if( ram->getHeight() + val > maxHö )
  268. ram->setSize( ram->getBreite(), maxHö );
  269. else
  270. ram->setSize( ram->getBreite(), ram->getHeight() + val );
  271. rend = 1;
  272. }
  273. }
  274. }
  275. bool ret = rend;
  276. rend = 0;
  277. return ret;
  278. }
  279. void AccountSUKListeSpiel::doPublicMausEreignis( MausEreignis &me )
  280. {
  281. bool vera = me.verarbeitet;
  282. details->doPublicMausEreignis( me );
  283. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  284. {
  285. if( details->zHintergrundBild() == ausklappen )
  286. {
  287. details->setHintergrundBildZ( dynamic_cast<Bild *>( einklappen->getThis() ) );
  288. // TODO: details->zToolTip()->setText( "Karten verbergen." );
  289. }
  290. else
  291. {
  292. details->setHintergrundBildZ( dynamic_cast<Bild *>( ausklappen->getThis() ) );
  293. // TODO: details->zToolTip()->setText( "Karten anzeigen." );
  294. }
  295. }
  296. }
  297. void AccountSUKListeSpiel::render( int yOff, Bild &zRObj )
  298. {
  299. if( !zRObj.setDrawOptions( 10, yOff, ram->getBreite(), ram->getHeight() ) )
  300. return;
  301. nameTF->render( zRObj );
  302. spieleTF->render( zRObj );
  303. gewonnenTF->render( zRObj );
  304. punkteTF->render( zRObj );
  305. statusTF->render( zRObj );
  306. details->render( zRObj );
  307. ram->render( zRObj );
  308. if( ram->getHeight() > 20 )
  309. {
  310. zRObj.drawLinieH( 0, 20, ram->getBreite(), ram->getFarbe() );
  311. if( !zRObj.setDrawOptions( 1, 25, ram->getBreite() - 2, ram->getHeight() - 2 ) )
  312. {
  313. zRObj.releaseDrawOptions();
  314. return;
  315. }
  316. int anz = karten->getEintragAnzahl();
  317. int *arr = new int[ anz ];
  318. anz = getReihenfolge( arr );
  319. yOff = 0;
  320. for( int i = 0; i < anz; i++ )
  321. {
  322. karten->z( arr[ i ] )->render( yOff, zRObj );
  323. yOff += 25;
  324. }
  325. delete[]arr;
  326. zRObj.releaseDrawOptions();
  327. }
  328. zRObj.releaseDrawOptions();
  329. }
  330. // constant
  331. int AccountSUKListeSpiel::getHeight() const
  332. {
  333. return ram->getHeight();
  334. }
  335. Text *AccountSUKListeSpiel::zName() const
  336. {
  337. return name;
  338. }
  339. int AccountSUKListeSpiel::getSpiele() const
  340. {
  341. return spiele;
  342. }
  343. int AccountSUKListeSpiel::getGewonnen() const
  344. {
  345. return gewonnen;
  346. }
  347. int AccountSUKListeSpiel::getPunkte() const
  348. {
  349. return punkte;
  350. }
  351. Text *AccountSUKListeSpiel::zStatus() const
  352. {
  353. return status;
  354. }
  355. // Inhalt der AccountSUKListe Klasse aus AccountSpieleUndKarten.h
  356. // Konstruktor
  357. AccountSUKListe::AccountSUKListe()
  358. : Zeichnung(),
  359. ram( new LRahmen() ),
  360. scroll( new VScrollBar() ),
  361. spiele( new RCArray< AccountSUKListeSpiel >() ),
  362. status( new Text() ),
  363. statusFilter( new Text( "Alle" ) ),
  364. sortSpalte( new Text( "Name" ) ),
  365. sortAbsteigend( 0 ),
  366. rend( 0 )
  367. {
  368. pos = Punkt( 10, 40 );
  369. ram->setSize( 760, 380 );
  370. ram->setFarbe( 0xFFFFFFFF );
  371. ram->setRamenBreite( 1 );
  372. }
  373. // Destruktor
  374. AccountSUKListe::~AccountSUKListe()
  375. {
  376. ram->release();
  377. scroll->release();
  378. spiele->release();
  379. status->release();
  380. statusFilter->release();
  381. sortSpalte->release();
  382. }
  383. // privat
  384. int AccountSUKListe::getReihenfolge( int *arr )
  385. {
  386. int anz = spiele->getEintragAnzahl();
  387. if( !anz )
  388. return 0;
  389. int ret = 0;
  390. bool *fertig = new bool[ anz ];
  391. ZeroMemory( fertig, anz );
  392. for( int i = 0; i < anz; i++ )
  393. {
  394. int index = -1;
  395. int minMax = 0;
  396. Text minMaxT;
  397. for( int j = 0; j < anz; j++ )
  398. {
  399. AccountSUKListeSpiel *tmp = spiele->z( j );
  400. if( !statusFilter->istGleich( "Alle" ) && !tmp->zStatus()->istGleich( statusFilter->getText() ) )
  401. continue;
  402. if( sortSpalte->istGleich( "Name" ) && !fertig[ j ] && ( index < 0 ||
  403. ( sortAbsteigend && *tmp->zName() > minMaxT ) || ( !sortAbsteigend && *tmp->zName() < minMaxT ) ) )
  404. {
  405. minMaxT = tmp->zName()->getText();
  406. index = j;
  407. }
  408. else if( sortSpalte->istGleich( "Spiele" ) && !fertig[ j ] && ( index < 0 ||
  409. ( sortAbsteigend && tmp->getSpiele() > minMax ) || ( !sortAbsteigend && tmp->getSpiele() < minMax ) ) )
  410. {
  411. minMax = tmp->getSpiele();
  412. index = j;
  413. }
  414. else if( sortSpalte->istGleich( "Gewonnen" ) && !fertig[ j ] && ( index < 0 ||
  415. ( sortAbsteigend && tmp->getGewonnen() > minMax ) || ( !sortAbsteigend && tmp->getGewonnen() < minMax ) ) )
  416. {
  417. minMax = tmp->getGewonnen();
  418. index = j;
  419. }
  420. else if( sortSpalte->istGleich( "Punkte" ) && !fertig[ j ] && ( index < 0 ||
  421. ( sortAbsteigend && tmp->getPunkte() > minMax ) || ( !sortAbsteigend && tmp->getPunkte() < minMax ) ) )
  422. {
  423. minMax = tmp->getPunkte();
  424. index = j;
  425. }
  426. else if( sortSpalte->istGleich( "Status" ) && !fertig[ j ] && ( index < 0 ||
  427. ( sortAbsteigend && *tmp->zStatus() > minMaxT ) || ( !sortAbsteigend && *tmp->zStatus() < minMaxT ) ) )
  428. {
  429. minMaxT = tmp->zStatus()->getText();
  430. index = j;
  431. }
  432. }
  433. if( index < 0 )
  434. break;
  435. fertig[ index ] = 1;
  436. arr[ ret ] = index;
  437. ret++;
  438. }
  439. delete[] fertig;
  440. return ret;
  441. }
  442. // nicht constant
  443. void AccountSUKListe::reset()
  444. {
  445. lockZeichnung();
  446. spiele->leeren();
  447. unlockZeichnung();
  448. }
  449. void AccountSUKListe::addSpiel( AccountSUKListeSpiel *spiel )
  450. {
  451. lockZeichnung();
  452. spiel->setSortRichtung( sortAbsteigend );
  453. spiel->setSortSpalte( sortSpalte->getText() );
  454. spiel->setStatusAusw( statusFilter->getText() );
  455. spiele->add( spiel );
  456. unlockZeichnung();
  457. }
  458. void AccountSUKListe::setStatusAusw( char *status )
  459. {
  460. lockZeichnung();
  461. this->statusFilter->setText( status );
  462. int anz = spiele->getEintragAnzahl();
  463. for( int i = 0; i < anz; i++ )
  464. spiele->z( i )->setStatusAusw( status );
  465. unlockZeichnung();
  466. rend = 1;
  467. }
  468. void AccountSUKListe::setSortSpalte( char *spalte )
  469. {
  470. lockZeichnung();
  471. this->sortSpalte->setText( spalte );
  472. int anz = spiele->getEintragAnzahl();
  473. for( int i = 0; i < anz; i++ )
  474. spiele->z( i )->setSortSpalte( spalte );
  475. unlockZeichnung();
  476. rend = 1;
  477. }
  478. void AccountSUKListe::setSortRichtung( bool absteigend )
  479. {
  480. lockZeichnung();
  481. sortAbsteigend = absteigend;
  482. int anz = spiele->getEintragAnzahl();
  483. for( int i = 0; i < anz; i++ )
  484. spiele->z( i )->setSortRichtung( absteigend );
  485. unlockZeichnung();
  486. rend = 1;
  487. }
  488. bool AccountSUKListe::tick( double tickVal )
  489. {
  490. lockZeichnung();
  491. int anz = spiele->getEintragAnzahl();
  492. if( anz > 0 )
  493. {
  494. int *rf = new int[ anz ];
  495. int rfAnz = getReihenfolge( rf );
  496. for( int i = 0; i < rfAnz; i++ )
  497. rend |= spiele->z( rf[ i ] )->tick( tickVal );
  498. delete[] rf;
  499. }
  500. unlockZeichnung();
  501. rend |= scroll->getRend();
  502. bool ret = rend;
  503. rend = 0;
  504. return ret;
  505. }
  506. void AccountSUKListe::doPublicMausEreignis( MausEreignis &me )
  507. {
  508. bool vera = 0;
  509. if( me.mx - pos.x <= 0 || me.mx - pos.x >= ram->getBreite() || me.my - pos.y <= 0 || me.my - pos.y >= ram->getHeight() )
  510. {
  511. vera = 1;
  512. me.verarbeitet = 1;
  513. }
  514. int mx = me.mx, my = me.my;
  515. me.mx -= pos.x;
  516. me.my -= pos.y;
  517. scroll->doMausMessage( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, me );
  518. me.mx -= 10;
  519. me.my -= 10 - scroll->getScroll();
  520. lockZeichnung();
  521. int anz = spiele->getEintragAnzahl();
  522. int *rf = new int[ anz ];
  523. int rfAnz = getReihenfolge( rf );
  524. for( int i = 0; i < rfAnz; i++ )
  525. {
  526. spiele->z( rf[ i ] )->doPublicMausEreignis( me );
  527. me.my -= spiele->z( rf[ i ] )->getHeight() + 10;
  528. }
  529. delete[] rf;
  530. unlockZeichnung();
  531. me.mx = mx, me.my = my;
  532. if( vera )
  533. me.verarbeitet = 0;
  534. }
  535. void AccountSUKListe::render( Bild &zRObj )
  536. {
  537. if( !zRObj.setDrawOptions( pos.x, pos.y, ram->getBreite(), ram->getBreite() ) )
  538. return;
  539. ram->render( zRObj );
  540. scroll->render( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, zRObj );
  541. if( !zRObj.setDrawOptions( 1, 1, ram->getBreite() - 15, ram->getHeight() - 2 ) )
  542. {
  543. zRObj.releaseDrawOptions();
  544. return;
  545. }
  546. int y = -scroll->getScroll();
  547. int anzHö = 10;
  548. lockZeichnung();
  549. int anz = spiele->getEintragAnzahl();
  550. int *rf = new int[ anz ];
  551. int rfAnz = getReihenfolge( rf );
  552. for( int i = 0; i < rfAnz; i++ )
  553. {
  554. spiele->z( rf[ i ] )->render( anzHö, zRObj );
  555. anzHö += spiele->z( rf[ i ] )->getHeight() + 10;
  556. }
  557. delete[] rf;
  558. unlockZeichnung();
  559. scroll->update( anzHö, ram->getHeight() - 2 );
  560. zRObj.releaseDrawOptions();
  561. zRObj.releaseDrawOptions();
  562. }
  563. #define ABSTYLE AuswahlBox::Style::Sichtbar | AuswahlBox::Style::Erlaubt | AuswahlBox::Style::Rahmen | AuswahlBox::Style::AuswahlBuffer | AuswahlBox::Style::MausBuffer | AuswahlBox::Style::MaxHeight | AuswahlBox::Style::Hintergrund | AuswahlBox::Style::VScroll
  564. // Inhalt der AccountSpieleUndKarten Klasse aus AccountSpieleUndKarten.h
  565. // Konstruktor
  566. AccountSpieleUndKarten::AccountSpieleUndKarten()
  567. : Thread(),
  568. spieleUndKartenF( initFenster( 810, 40, 780, 450, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Rahmen | Fenster::Style::Erlaubt, "Spiele und Karten von " ) ),
  569. statusAusw( initAuswahlBox( 10, 10, 150, 20, ABSTYLE, { "Alle", "Im Besitz", "Nicht im Besitz" } ) ),
  570. sortSpalte( initAuswahlBox( 170, 10, 150, 20, ABSTYLE, { "Name", "Spiele", "Gewonnen", "Punkte", "Status" } ) ),
  571. sortRichtung( initAuswahlBox( 330, 10, 150, 20, ABSTYLE, { "Aufwärts", "Abwärts" } ) ),
  572. liste( new AccountSUKListe() ),
  573. status( 0 ),
  574. accId( 0 ),
  575. animation( 0 ),
  576. alpha( 255 ),
  577. tickVal( 0 ),
  578. rend( 0 )
  579. {
  580. initToolTip( statusAusw, "Wähle den Status der anzuzeigenden Spiele und Karten aus." );
  581. initToolTip( sortSpalte, "Wähle aus, nach welcher Spalte die\nTabelle sortiert werden soll." );
  582. initToolTip( sortRichtung, "Wähle aus, Ob Aufwärts oder Abwärts sortiert werden soll." );
  583. spieleUndKartenF->addMember( dynamic_cast<Zeichnung *>( liste->getThis() ) );
  584. spieleUndKartenF->addMember( dynamic_cast<Zeichnung *>( statusAusw->getThis() ) );
  585. spieleUndKartenF->addMember( dynamic_cast<Zeichnung *>( sortSpalte->getThis() ) );
  586. spieleUndKartenF->addMember( dynamic_cast<Zeichnung *>( sortRichtung->getThis() ) );
  587. spieleUndKartenF->setMausEreignis( _ret1ME );
  588. }
  589. // Destruktor
  590. AccountSpieleUndKarten::~AccountSpieleUndKarten()
  591. {
  592. spieleUndKartenF->release();
  593. statusAusw->release();
  594. sortSpalte->release();
  595. sortRichtung->release();
  596. liste->release();
  597. }
  598. // nicht constant
  599. void AccountSpieleUndKarten::reset()
  600. {
  601. liste->reset();
  602. }
  603. void AccountSpieleUndKarten::ladeStatistik( int accId )
  604. {
  605. if( this->accId == accId )
  606. return;
  607. this->status = 0;
  608. if( run )
  609. {
  610. warteAufThread( 1000 );
  611. ende();
  612. }
  613. if( ( animation | 0x1 ) == animation )
  614. {
  615. animation |= 0x4;
  616. this->accId = accId;
  617. this->status = 1;
  618. return;
  619. }
  620. if( this->accId )
  621. reset();
  622. this->accId = accId;
  623. start();
  624. this->status = 1;
  625. }
  626. void AccountSpieleUndKarten::thread()
  627. {
  628. Text *name = infoClient->getSpielerName( accId );
  629. if( name )
  630. {
  631. name->insert( 0, "Spiele und Karten von " );
  632. spieleUndKartenF->setTitel( *name );
  633. name->release();
  634. }
  635. Array< int > *spiele = infoClient->getAccountSpielGespieltListe( accId );
  636. if( spiele )
  637. {
  638. int anz = spiele->getEintragAnzahl();
  639. for( int i = 0; i < anz; i++ )
  640. {
  641. AccountSUKListeSpiel *s = new AccountSUKListeSpiel( spiele->get( i ), accId );
  642. liste->addSpiel( s );
  643. }
  644. spiele->release();
  645. }
  646. else
  647. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Fehler beim laden der Daten." ), new Text( "Ok" ) );
  648. animation &= ~0x4;
  649. status = 2;
  650. run = 0;
  651. }
  652. void AccountSpieleUndKarten::setSichtbar( bool sichtbar, bool nachRechts )
  653. {
  654. if( sichtbar )
  655. {
  656. if( ( animation | 0x1 ) != animation || ( ( nachRechts && ( animation | 0x2 ) != animation ) || !nachRechts && ( animation | 0x2 ) == animation ) )
  657. {
  658. if( nachRechts )
  659. spieleUndKartenF->setPosition( -810, 40 );
  660. else
  661. spieleUndKartenF->setPosition( 810, 40 );
  662. }
  663. animation |= 0x1;
  664. }
  665. else
  666. animation &= ~0x1;
  667. if( nachRechts )
  668. animation |= 0x2;
  669. else
  670. animation &= ~0x2;
  671. }
  672. bool AccountSpieleUndKarten::tick( double zeit )
  673. {
  674. rend |= spieleUndKartenF->tick( zeit );
  675. tickVal += zeit;
  676. int valA = (int)( tickVal * 150 );
  677. int valB = (int)( tickVal * 500 );
  678. tickVal -= valA / 150.0;
  679. if( valA )
  680. {
  681. if( ( animation | 0x4 ) == animation && alpha )
  682. {
  683. if( alpha - valA <= 0 )
  684. alpha = 0;
  685. else
  686. alpha -= valA;
  687. rend = 1;
  688. if( !alpha )
  689. {
  690. reset();
  691. start();
  692. }
  693. }
  694. if( ( animation | 0x4 ) != animation && alpha != 255 )
  695. {
  696. if( alpha + valA >= 255 )
  697. alpha = 255;
  698. else
  699. alpha += valA;
  700. rend = 1;
  701. }
  702. }
  703. if( valB )
  704. {
  705. if( ( animation | 0x1 ) == animation )
  706. { // Sichtbar
  707. if( ( animation | 0x2 ) == animation )
  708. { // Nach Rechts
  709. if( spieleUndKartenF->getX() != 10 )
  710. {
  711. if( spieleUndKartenF->getX() + valB > 10 )
  712. spieleUndKartenF->setPosition( 10, spieleUndKartenF->getY() );
  713. else
  714. spieleUndKartenF->setPosition( spieleUndKartenF->getX() + valB, spieleUndKartenF->getY() );
  715. rend = 1;
  716. }
  717. }
  718. else
  719. { // Nach Links
  720. if( spieleUndKartenF->getX() != 10 )
  721. {
  722. if( spieleUndKartenF->getX() - valB < 10 )
  723. spieleUndKartenF->setPosition( 10, spieleUndKartenF->getY() );
  724. else
  725. spieleUndKartenF->setPosition( spieleUndKartenF->getX() - valB, spieleUndKartenF->getY() );
  726. rend = 1;
  727. }
  728. }
  729. }
  730. else
  731. { // Unsichtbar
  732. if( ( animation | 0x2 ) == animation )
  733. { // Nach Rechts
  734. if( spieleUndKartenF->getX() != 810 )
  735. {
  736. if( spieleUndKartenF->getX() + valB > 810 )
  737. spieleUndKartenF->setPosition( 810, spieleUndKartenF->getY() );
  738. else
  739. spieleUndKartenF->setPosition( spieleUndKartenF->getX() + valB, spieleUndKartenF->getY() );
  740. rend = 1;
  741. }
  742. }
  743. else
  744. { // Nach Links
  745. if( spieleUndKartenF->getX() != -810 )
  746. {
  747. if( spieleUndKartenF->getX() - valB < -810 )
  748. spieleUndKartenF->setPosition( -810, spieleUndKartenF->getY() );
  749. else
  750. spieleUndKartenF->setPosition( spieleUndKartenF->getX() - valB, spieleUndKartenF->getY() );
  751. rend = 1;
  752. }
  753. }
  754. }
  755. }
  756. bool ret = rend;
  757. rend = 0;
  758. return ret;
  759. }
  760. void AccountSpieleUndKarten::doPublicMausEreignis( MausEreignis &me )
  761. {
  762. int statusAuswS = statusAusw->getAuswahl();
  763. int sortSpalteS = sortSpalte->getAuswahl();
  764. int sortRichtungS = sortRichtung->getAuswahl();
  765. spieleUndKartenF->doPublicMausEreignis( me );
  766. if( statusAusw->getAuswahl() != statusAuswS )
  767. {
  768. liste->setStatusAusw( statusAusw->zEintrag( statusAusw->getAuswahl() )->zText()->getText() );
  769. statusAusw->einklappen();
  770. }
  771. if( sortSpalte->getAuswahl() != sortSpalteS )
  772. {
  773. liste->setSortSpalte( sortSpalte->zEintrag( sortSpalte->getAuswahl() )->zText()->getText() );
  774. sortSpalte->einklappen();
  775. }
  776. if( sortRichtung->getAuswahl() != sortRichtungS )
  777. {
  778. liste->setSortRichtung( sortRichtung->getAuswahl() != 0 );
  779. sortRichtung->einklappen();
  780. }
  781. }
  782. void AccountSpieleUndKarten::render( Bild &zRObj )
  783. {
  784. zRObj.setAlpha( alpha );
  785. spieleUndKartenF->render( zRObj );
  786. zRObj.releaseAlpha();
  787. }
  788. // constant
  789. int AccountSpieleUndKarten::getStatus() const
  790. {
  791. return status;
  792. }