AccountSpieleUndKarten.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  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( "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, hauptScreen );
  137. name = infoClient->getSpielName( id );
  138. if( name )
  139. nameTF->zText()->append( name->getText() );
  140. Array< int > *stat = new Array< int >();
  141. if( infoClient->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( infoClient->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 = infoClient->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. // TODO: details->zToolTip()->setText( "Karten verbergen." );
  319. }
  320. else
  321. {
  322. details->setHintergrundBildZ( ausklappen->getThis() );
  323. // TODO: 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. {
  411. pos = Punkt( 10, 40 );
  412. ram->setSize( 760, 380 );
  413. ram->setFarbe( 0xFFFFFFFF );
  414. ram->setRamenBreite( 1 );
  415. }
  416. // Destruktor
  417. AccountSUKListe::~AccountSUKListe()
  418. {
  419. ram->release();
  420. scroll->release();
  421. spiele->release();
  422. status->release();
  423. statusFilter->release();
  424. sortSpalte->release();
  425. }
  426. // privat
  427. int AccountSUKListe::getReihenfolge( int *arr )
  428. {
  429. int anz = spiele->getEintragAnzahl();
  430. if( !anz )
  431. return 0;
  432. int ret = 0;
  433. bool *fertig = new bool[ anz ];
  434. ZeroMemory( fertig, anz );
  435. for( int i = 0; i < anz; i++ )
  436. {
  437. int index = -1;
  438. int minMax = 0;
  439. Text minMaxT;
  440. for( int j = 0; j < anz; j++ )
  441. {
  442. AccountSUKListeSpiel *tmp = spiele->z( j );
  443. if( !statusFilter->istGleich( "Alle" ) && !tmp->zStatus()->istGleich( statusFilter->getText() ) )
  444. continue;
  445. if( sortSpalte->istGleich( "Name" ) && !fertig[ j ] && ( index < 0 ||
  446. ( sortAbsteigend && *tmp->zName() > minMaxT ) || ( !sortAbsteigend && *tmp->zName() < minMaxT ) ) )
  447. {
  448. minMaxT = tmp->zName()->getText();
  449. index = j;
  450. }
  451. else if( sortSpalte->istGleich( "Spiele" ) && !fertig[ j ] && ( index < 0 ||
  452. ( sortAbsteigend && tmp->getSpiele() > minMax ) || ( !sortAbsteigend && tmp->getSpiele() < minMax ) ) )
  453. {
  454. minMax = tmp->getSpiele();
  455. index = j;
  456. }
  457. else if( sortSpalte->istGleich( "Gewonnen" ) && !fertig[ j ] && ( index < 0 ||
  458. ( sortAbsteigend && tmp->getGewonnen() > minMax ) || ( !sortAbsteigend && tmp->getGewonnen() < minMax ) ) )
  459. {
  460. minMax = tmp->getGewonnen();
  461. index = j;
  462. }
  463. else if( sortSpalte->istGleich( "Punkte" ) && !fertig[ j ] && ( index < 0 ||
  464. ( sortAbsteigend && tmp->getPunkte() > minMax ) || ( !sortAbsteigend && tmp->getPunkte() < minMax ) ) )
  465. {
  466. minMax = tmp->getPunkte();
  467. index = j;
  468. }
  469. else if( sortSpalte->istGleich( "Status" ) && !fertig[ j ] && ( index < 0 ||
  470. ( sortAbsteigend && *tmp->zStatus() > minMaxT ) || ( !sortAbsteigend && *tmp->zStatus() < minMaxT ) ) )
  471. {
  472. minMaxT = tmp->zStatus()->getText();
  473. index = j;
  474. }
  475. }
  476. if( index < 0 )
  477. break;
  478. fertig[ index ] = 1;
  479. arr[ ret ] = index;
  480. ret++;
  481. }
  482. delete[] fertig;
  483. return ret;
  484. }
  485. // nicht constant
  486. void AccountSUKListe::reset()
  487. {
  488. lockZeichnung();
  489. spiele->leeren();
  490. unlockZeichnung();
  491. }
  492. void AccountSUKListe::addSpiel( AccountSUKListeSpiel *spiel )
  493. {
  494. lockZeichnung();
  495. spiel->setSortRichtung( sortAbsteigend );
  496. spiel->setSortSpalte( sortSpalte->getText() );
  497. spiel->setStatusAusw( statusFilter->getText() );
  498. spiele->add( spiel );
  499. unlockZeichnung();
  500. }
  501. void AccountSUKListe::setStatusAusw( char *status )
  502. {
  503. lockZeichnung();
  504. this->statusFilter->setText( status );
  505. int anz = spiele->getEintragAnzahl();
  506. for( int i = 0; i < anz; i++ )
  507. spiele->z( i )->setStatusAusw( status );
  508. unlockZeichnung();
  509. rend = 1;
  510. }
  511. void AccountSUKListe::setSortSpalte( char *spalte )
  512. {
  513. lockZeichnung();
  514. this->sortSpalte->setText( spalte );
  515. int anz = spiele->getEintragAnzahl();
  516. for( int i = 0; i < anz; i++ )
  517. spiele->z( i )->setSortSpalte( spalte );
  518. unlockZeichnung();
  519. rend = 1;
  520. }
  521. void AccountSUKListe::setSortRichtung( bool absteigend )
  522. {
  523. lockZeichnung();
  524. sortAbsteigend = absteigend;
  525. int anz = spiele->getEintragAnzahl();
  526. for( int i = 0; i < anz; i++ )
  527. spiele->z( i )->setSortRichtung( absteigend );
  528. unlockZeichnung();
  529. rend = 1;
  530. }
  531. bool AccountSUKListe::tick( double tickVal )
  532. {
  533. lockZeichnung();
  534. int anz = spiele->getEintragAnzahl();
  535. if( anz > 0 )
  536. {
  537. int *rf = new int[ anz ];
  538. int rfAnz = getReihenfolge( rf );
  539. for( int i = 0; i < rfAnz; i++ )
  540. rend |= spiele->z( rf[ i ] )->tick( tickVal );
  541. delete[] rf;
  542. }
  543. unlockZeichnung();
  544. rend |= scroll->getRend();
  545. bool ret = rend;
  546. rend = 0;
  547. return ret;
  548. }
  549. void AccountSUKListe::doMausEreignis( MausEreignis &me )
  550. {
  551. bool vera = 0;
  552. if( me.mx - pos.x <= 0 || me.mx - pos.x >= ram->getBreite() || me.my - pos.y <= 0 || me.my - pos.y >= ram->getHeight() )
  553. {
  554. vera = 1;
  555. me.verarbeitet = 1;
  556. }
  557. int mx = me.mx, my = me.my;
  558. me.mx -= pos.x;
  559. me.my -= pos.y;
  560. scroll->doMausMessage( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, me );
  561. me.mx -= 10;
  562. me.my -= 10 - scroll->getScroll();
  563. lockZeichnung();
  564. int anz = spiele->getEintragAnzahl();
  565. int *rf = new int[ anz ];
  566. int rfAnz = getReihenfolge( rf );
  567. for( int i = 0; i < rfAnz; i++ )
  568. {
  569. spiele->z( rf[ i ] )->doMausEreignis( me );
  570. me.my -= spiele->z( rf[ i ] )->getHeight() + 10;
  571. }
  572. delete[] rf;
  573. unlockZeichnung();
  574. me.mx = mx, me.my = my;
  575. if( vera )
  576. me.verarbeitet = 0;
  577. }
  578. void AccountSUKListe::render( Bild &zRObj )
  579. {
  580. if( !zRObj.setDrawOptions( pos.x, pos.y, ram->getBreite(), ram->getBreite() ) )
  581. return;
  582. ram->render( zRObj );
  583. scroll->render( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, zRObj );
  584. if( !zRObj.setDrawOptions( 1, 1, ram->getBreite() - 15, ram->getHeight() - 2 ) )
  585. {
  586. zRObj.releaseDrawOptions();
  587. return;
  588. }
  589. int y = -scroll->getScroll();
  590. int anzHö = 10;
  591. lockZeichnung();
  592. int anz = spiele->getEintragAnzahl();
  593. int *rf = new int[ anz ];
  594. int rfAnz = getReihenfolge( rf );
  595. for( int i = 0; i < rfAnz; i++ )
  596. {
  597. spiele->z( rf[ i ] )->render( anzHö, zRObj );
  598. anzHö += spiele->z( rf[ i ] )->getHeight() + 10;
  599. }
  600. delete[] rf;
  601. unlockZeichnung();
  602. scroll->update( anzHö, ram->getHeight() - 2 );
  603. zRObj.releaseDrawOptions();
  604. zRObj.releaseDrawOptions();
  605. }
  606. #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
  607. // Inhalt der AccountSpieleUndKarten Klasse aus AccountSpieleUndKarten.h
  608. // Konstruktor
  609. AccountSpieleUndKarten::AccountSpieleUndKarten( Schrift *zSchrift )
  610. : Thread(),
  611. schrift( zSchrift->getThis() ),
  612. 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 " ) ),
  613. statusAusw( initAuswahlBox( 10, 10, 150, 20, zSchrift, ABSTYLE, { "Alle", "Im Besitz", "Nicht im Besitz" } ) ),
  614. sortSpalte( initAuswahlBox( 170, 10, 150, 20, zSchrift, ABSTYLE, { "Name", "Spiele", "Gewonnen", "Punkte", "Status" } ) ),
  615. sortRichtung( initAuswahlBox( 330, 10, 150, 20, zSchrift, ABSTYLE, { "Aufwärts", "Abwärts" } ) ),
  616. liste( new AccountSUKListe() ),
  617. status( 0 ),
  618. accId( 0 ),
  619. animation( 0 ),
  620. alpha( 255 ),
  621. tickVal( 0 ),
  622. rend( 0 )
  623. {
  624. initToolTip( statusAusw, "Wähle den Status der anzuzeigenden Spiele und Karten aus.", zSchrift, hauptScreen );
  625. initToolTip( sortSpalte, "Wähle aus, nach welcher Spalte die\nTabelle sortiert werden soll.", zSchrift, hauptScreen );
  626. initToolTip( sortRichtung, "Wähle aus, Ob Aufwärts oder Abwärts sortiert werden soll.", zSchrift, hauptScreen );
  627. spieleUndKartenF->addMember( liste->getThis() );
  628. spieleUndKartenF->addMember( statusAusw->getThis() );
  629. spieleUndKartenF->addMember( sortSpalte->getThis() );
  630. spieleUndKartenF->addMember( sortRichtung->getThis() );
  631. spieleUndKartenF->setMausEreignis( _ret1ME );
  632. }
  633. // Destruktor
  634. AccountSpieleUndKarten::~AccountSpieleUndKarten()
  635. {
  636. schrift->release();
  637. spieleUndKartenF->release();
  638. statusAusw->release();
  639. sortSpalte->release();
  640. sortRichtung->release();
  641. liste->release();
  642. }
  643. // nicht constant
  644. void AccountSpieleUndKarten::reset()
  645. {
  646. liste->reset();
  647. }
  648. void AccountSpieleUndKarten::ladeStatistik( int accId )
  649. {
  650. if( this->accId == accId )
  651. return;
  652. this->status = 0;
  653. if( run )
  654. {
  655. warteAufThread( 1000 );
  656. ende();
  657. }
  658. if( ( animation | 0x1 ) == animation )
  659. {
  660. animation |= 0x4;
  661. this->accId = accId;
  662. this->status = 1;
  663. return;
  664. }
  665. if( this->accId )
  666. reset();
  667. this->accId = accId;
  668. start();
  669. this->status = 1;
  670. }
  671. void AccountSpieleUndKarten::thread()
  672. {
  673. Text *name = infoClient->getSpielerName( accId );
  674. if( name )
  675. {
  676. name->insert( 0, "Spiele und Karten von " );
  677. spieleUndKartenF->setTitel( *name );
  678. name->release();
  679. }
  680. Array< int > *spiele = infoClient->getAccountSpielGespieltListe( accId );
  681. if( spiele )
  682. {
  683. int anz = spiele->getEintragAnzahl();
  684. for( int i = 0; i < anz; i++ )
  685. {
  686. AccountSUKListeSpiel *s = new AccountSUKListeSpiel( schrift, spiele->get( i ), accId );
  687. liste->addSpiel( s );
  688. }
  689. spiele->release();
  690. }
  691. else
  692. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Fehler beim laden der Daten." ), new Text( "Ok" ) );
  693. animation &= ~0x4;
  694. status = 2;
  695. run = 0;
  696. }
  697. void AccountSpieleUndKarten::setSichtbar( bool sichtbar, bool nachRechts )
  698. {
  699. if( sichtbar )
  700. {
  701. if( ( animation | 0x1 ) != animation || ( ( nachRechts && ( animation | 0x2 ) != animation ) || !nachRechts && ( animation | 0x2 ) == animation ) )
  702. {
  703. if( nachRechts )
  704. spieleUndKartenF->setPosition( -810, 40 );
  705. else
  706. spieleUndKartenF->setPosition( 810, 40 );
  707. }
  708. animation |= 0x1;
  709. }
  710. else
  711. animation &= ~0x1;
  712. if( nachRechts )
  713. animation |= 0x2;
  714. else
  715. animation &= ~0x2;
  716. }
  717. bool AccountSpieleUndKarten::tick( double zeit )
  718. {
  719. rend |= spieleUndKartenF->tick( zeit );
  720. tickVal += zeit;
  721. int valA = (int)( tickVal * 150 );
  722. int valB = (int)( tickVal * 500 );
  723. tickVal -= valA / 150.0;
  724. if( valA )
  725. {
  726. if( ( animation | 0x4 ) == animation && alpha )
  727. {
  728. if( alpha - valA <= 0 )
  729. alpha = 0;
  730. else
  731. alpha -= valA;
  732. rend = 1;
  733. if( !alpha )
  734. {
  735. reset();
  736. start();
  737. }
  738. }
  739. if( ( animation | 0x4 ) != animation && alpha != 255 )
  740. {
  741. if( alpha + valA >= 255 )
  742. alpha = 255;
  743. else
  744. alpha += valA;
  745. rend = 1;
  746. }
  747. }
  748. if( valB )
  749. {
  750. if( ( animation | 0x1 ) == animation )
  751. { // Sichtbar
  752. if( ( animation | 0x2 ) == animation )
  753. { // Nach Rechts
  754. if( spieleUndKartenF->getX() != 10 )
  755. {
  756. if( spieleUndKartenF->getX() + valB > 10 )
  757. spieleUndKartenF->setPosition( 10, spieleUndKartenF->getY() );
  758. else
  759. spieleUndKartenF->setPosition( spieleUndKartenF->getX() + valB, spieleUndKartenF->getY() );
  760. rend = 1;
  761. }
  762. }
  763. else
  764. { // Nach Links
  765. if( spieleUndKartenF->getX() != 10 )
  766. {
  767. if( spieleUndKartenF->getX() - valB < 10 )
  768. spieleUndKartenF->setPosition( 10, spieleUndKartenF->getY() );
  769. else
  770. spieleUndKartenF->setPosition( spieleUndKartenF->getX() - valB, spieleUndKartenF->getY() );
  771. rend = 1;
  772. }
  773. }
  774. }
  775. else
  776. { // Unsichtbar
  777. if( ( animation | 0x2 ) == animation )
  778. { // Nach Rechts
  779. if( spieleUndKartenF->getX() != 810 )
  780. {
  781. if( spieleUndKartenF->getX() + valB > 810 )
  782. spieleUndKartenF->setPosition( 810, spieleUndKartenF->getY() );
  783. else
  784. spieleUndKartenF->setPosition( spieleUndKartenF->getX() + valB, spieleUndKartenF->getY() );
  785. rend = 1;
  786. }
  787. }
  788. else
  789. { // Nach Links
  790. if( spieleUndKartenF->getX() != -810 )
  791. {
  792. if( spieleUndKartenF->getX() - valB < -810 )
  793. spieleUndKartenF->setPosition( -810, spieleUndKartenF->getY() );
  794. else
  795. spieleUndKartenF->setPosition( spieleUndKartenF->getX() - valB, spieleUndKartenF->getY() );
  796. rend = 1;
  797. }
  798. }
  799. }
  800. }
  801. bool ret = rend;
  802. rend = 0;
  803. return ret;
  804. }
  805. void AccountSpieleUndKarten::doMausEreignis( MausEreignis &me )
  806. {
  807. int statusAuswS = statusAusw->getAuswahl();
  808. int sortSpalteS = sortSpalte->getAuswahl();
  809. int sortRichtungS = sortRichtung->getAuswahl();
  810. spieleUndKartenF->doMausEreignis( me );
  811. if( statusAusw->getAuswahl() != statusAuswS )
  812. {
  813. liste->setStatusAusw( statusAusw->zEintrag( statusAusw->getAuswahl() )->zText()->getText() );
  814. statusAusw->einklappen();
  815. }
  816. if( sortSpalte->getAuswahl() != sortSpalteS )
  817. {
  818. liste->setSortSpalte( sortSpalte->zEintrag( sortSpalte->getAuswahl() )->zText()->getText() );
  819. sortSpalte->einklappen();
  820. }
  821. if( sortRichtung->getAuswahl() != sortRichtungS )
  822. {
  823. liste->setSortRichtung( sortRichtung->getAuswahl() != 0 );
  824. sortRichtung->einklappen();
  825. }
  826. }
  827. void AccountSpieleUndKarten::render( Bild &zRObj )
  828. {
  829. zRObj.setAlpha( alpha );
  830. spieleUndKartenF->render( zRObj );
  831. zRObj.releaseAlpha();
  832. }
  833. // constant
  834. int AccountSpieleUndKarten::getStatus() const
  835. {
  836. return status;
  837. }