AccountSpieleUndKarten.cpp 23 KB

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