AccountSpieleUndKarten.cpp 23 KB

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