AccountHistorie.cpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  1. #include "AccountHistorie.h"
  2. #include "../../../Global/Initialisierung.h"
  3. #include "../../../Leser/KartenLeser.h"
  4. #include "../../../Global/Variablen.h"
  5. #include <Text.h>
  6. #include <Rahmen.h>
  7. #include <DateiSystem.h>
  8. #include <Zeit.h>
  9. #include <Punkt.h>
  10. #include <Globals.h>
  11. typedef AccountHistorieStatistikV* ( *AHSSDLLStart )( void );
  12. typedef AufzeichnungV* ( *AHSADLLStart )( void );
  13. // Inahlt der AHSpielStatistik Klasse aus AccountHistorie.h
  14. // Konstruktor
  15. AHSpielStatistik::AHSpielStatistik( Schrift *schrift )
  16. : Thread(),
  17. schrift( schrift )
  18. {
  19. statistikF = initFenster( 10, 40, 780, 450, schrift, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Rahmen, "Spiel Ergebnis" );
  20. laden = (Animation2D*)ladeAnimation->dublizieren();
  21. laden->setSichtbar( 0 );
  22. laden->setPosition( 380, 245 );
  23. dllName = new Text( "" );
  24. dllHandle = 0;
  25. alpha = 0;
  26. sichtbar = 0;
  27. statistik = 0;
  28. tickVal = 0;
  29. }
  30. // Destruktor
  31. AHSpielStatistik::~AHSpielStatistik()
  32. {
  33. statistikF->release();
  34. if( dllHandle )
  35. reset();
  36. dllName->release();
  37. schrift->release();
  38. laden->release();
  39. }
  40. // nicht constant
  41. void AHSpielStatistik::reset()
  42. {
  43. if( run )
  44. warteAufThread( INFINITE );
  45. if( dllHandle )
  46. {
  47. if( statistik )
  48. statistik = statistik->release();
  49. Framework::getDLLRegister()->releaseDLL( *dllName );
  50. dllHandle = 0;
  51. }
  52. }
  53. bool AHSpielStatistik::ladeDaten( int spielId, int karteId )
  54. {
  55. if( dllHandle )
  56. reset();
  57. KartenLeser *reader = KartenLeser::getInstance();
  58. reader->lock();
  59. reader->setKarteId( karteId );
  60. Text *pfad = reader->getSpielPfad();
  61. if( !pfad )
  62. {
  63. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( reader->getLetzterFehler() ), new Text( "Ok" ) );
  64. reader->unlock();
  65. reader->release();
  66. return 0;
  67. }
  68. pfad->append( "bin/" );
  69. Text *spielArtName = reader->getSpielName();
  70. if( !spielArtName )
  71. {
  72. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( reader->getLetzterFehler() ), new Text( "Ok" ) );
  73. reader->unlock();
  74. reader->release();
  75. pfad->release();
  76. return 0;
  77. }
  78. pfad->append( spielArtName->getText() );
  79. pfad->append( ".dll" );
  80. reader->unlock();
  81. reader->release();
  82. dllName->setText( "Spiele/" );
  83. dllName->append( spielArtName->getText() );
  84. dllName->append( ".dll" );
  85. spielArtName->release();
  86. dllHandle = Framework::getDLLRegister()->ladeDLL( *dllName, *pfad );
  87. if( !dllHandle )
  88. {
  89. Text *msg = new Text( "Die DLL Datei '" );
  90. msg->append( pfad->getText() );
  91. msg->append( "' konnte nicht geladen werden." );
  92. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), msg, new Text( "Ok" ) );
  93. pfad->release();
  94. return 0;
  95. }
  96. AHSSDLLStart startFunk = (AHSSDLLStart)GetProcAddress( dllHandle, "GetAccountHistorieStatistik" );
  97. if( !startFunk )
  98. {
  99. if( dllHandle )
  100. {
  101. Framework::getDLLRegister()->releaseDLL( *dllName );
  102. dllHandle = 0;
  103. }
  104. Text *msg = new Text( "Die Funktion 'GetAccountHistorieStatistik' konnte in der DLL Datei '" );
  105. msg->append( pfad->getText() );
  106. msg->append( "' nicht gefunden werden." );
  107. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), msg, new Text( "Ok" ) );
  108. pfad->release();
  109. return 0;
  110. }
  111. pfad->release();
  112. statistik = startFunk();
  113. if( !statistik )
  114. {
  115. if( dllHandle )
  116. {
  117. Framework::getDLLRegister()->releaseDLL( *dllName );
  118. dllHandle = 0;
  119. }
  120. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Für diese Spielart ist keine genauere Ansicht der Spiel Ergebnisse verfügbar." ), new Text( "Ok" ) );
  121. return 0;
  122. }
  123. this->spielId = spielId;
  124. statistik->setSchrift( schrift->getThis() );
  125. statistik->setBildschirm( hauptScreen );
  126. start();
  127. return 1;
  128. }
  129. void AHSpielStatistik::thread()
  130. {
  131. laden->setSichtbar( 1 );
  132. KSGClient::HistorieServerClient *historieClient = infoClient->createHistorieServerClient( spielId );
  133. if( !historieClient )
  134. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( infoClient->getLetzterFehler() ), new Text( "Ok" ) );
  135. else
  136. {
  137. if( !historieClient->downloadSpielHistorie() )
  138. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( historieClient->getLetzterFehler() ), new Text( "Ok" ) );
  139. else
  140. {
  141. statistik->ladeDaten( spielId );
  142. if( sichtbar )
  143. statistik->setSichtbar( 1 );
  144. laden->setSichtbar( 0 );
  145. historieClient->release();
  146. return;
  147. }
  148. historieClient->release();
  149. }
  150. laden->setSichtbar( 0 );
  151. setSichtbar( 0 );
  152. }
  153. void AHSpielStatistik::setPosition( int x, int y )
  154. {
  155. statistikF->setPosition( x, y );
  156. }
  157. void AHSpielStatistik::setSichtbar( bool sichtbar )
  158. {
  159. if( !statistik )
  160. return;
  161. if( !run )
  162. statistik->setSichtbar( sichtbar );
  163. this->sichtbar = sichtbar;
  164. if( sichtbar && !alpha )
  165. alpha = 1;
  166. }
  167. void AHSpielStatistik::doMausEreignis( MausEreignis &me )
  168. {
  169. if( !statistik || alpha != 255 )
  170. return;
  171. me.mx -= 1 + statistikF->getX();
  172. me.my -= 20 + statistikF->getY();
  173. statistik->doMausEreignis( me );
  174. if( statistik->wurdeGeschlossen() )
  175. setSichtbar( 0 );
  176. me.mx += 1 + statistikF->getX();
  177. me.my += 20 + statistikF->getY();
  178. }
  179. void AHSpielStatistik::doTastaturEreignis( TastaturEreignis &te )
  180. {
  181. if( !statistik || alpha != 255 )
  182. return;
  183. statistik->doTastaturEreignis( te );
  184. }
  185. bool AHSpielStatistik::tick( double tickVal )
  186. {
  187. if( !statistik || !alpha )
  188. return 0;
  189. bool ret = statistik->tick( tickVal );
  190. ret |= laden->tick( tickVal );
  191. this->tickVal += tickVal * 150;
  192. int val = ( int )this->tickVal;
  193. this->tickVal -= val;
  194. if( val )
  195. {
  196. if( sichtbar && alpha != 255 )
  197. {
  198. if( alpha + val > 255 )
  199. alpha = 255;
  200. else
  201. alpha += (unsigned char)val;
  202. ret = 1;
  203. }
  204. if( !sichtbar && alpha )
  205. {
  206. if( alpha - val < 0 )
  207. alpha = 0;
  208. else
  209. alpha -= (unsigned char)val;
  210. if( !alpha && statistik->istNochSichtbar() )
  211. alpha = 1;
  212. ret = 1;
  213. }
  214. }
  215. return ret;
  216. }
  217. void AHSpielStatistik::render( Bild &zRObj )
  218. {
  219. if( !statistik || !alpha )
  220. return;
  221. zRObj.setAlpha( alpha );
  222. statistikF->render( zRObj );
  223. if( !zRObj.setDrawOptions( statistikF->getX() + 1, statistikF->getY() + 21, statistikF->getBreite() - 2, statistikF->getHeight() - 22 ) )
  224. {
  225. zRObj.releaseAlpha();
  226. return;
  227. }
  228. statistik->render( zRObj );
  229. zRObj.releaseDrawOptions();
  230. laden->render( zRObj );
  231. zRObj.releaseAlpha();
  232. }
  233. // constant
  234. bool AHSpielStatistik::istNochSichtbar() const
  235. {
  236. if( alpha )
  237. return 1;
  238. return statistik ? statistik->istNochSichtbar() : 0;
  239. }
  240. // löscht das objekt wenn es nicht mehr gebraucht wird und beendet den Thread
  241. Thread *AHSpielStatistik::release()
  242. {
  243. if( ref == 2 && run )
  244. warteAufThread( INFINITE );
  245. return Thread::release();
  246. }
  247. // Inahlt der AHSpielVideo Klasse aus AccountHistorie.h
  248. // Konstruktor
  249. AHSpielVideo::AHSpielVideo( Schrift *schrift )
  250. : Thread(),
  251. schrift( schrift )
  252. {
  253. videoF = initFenster( 10, 40, 780, 450, schrift, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Rahmen, "Spiel Aufzeichnung" );
  254. laden = (Animation2D*)ladeAnimation->dublizieren();
  255. laden->setSichtbar( 0 );
  256. laden->setPosition( 380, 245 );
  257. dllName = new Text( "" );
  258. dllHandle = 0;
  259. alpha = 0;
  260. sichtbar = 0;
  261. video = 0;
  262. tickVal = 0;
  263. }
  264. // Destruktor
  265. AHSpielVideo::~AHSpielVideo()
  266. {
  267. videoF->release();
  268. if( dllHandle )
  269. reset();
  270. dllName->release();
  271. schrift->release();
  272. laden->release();
  273. }
  274. // nicht constant
  275. void AHSpielVideo::reset()
  276. {
  277. if( run )
  278. warteAufThread( INFINITE );
  279. if( dllHandle )
  280. {
  281. if( video )
  282. video = video->release();
  283. Framework::getDLLRegister()->releaseDLL( *dllName );
  284. dllHandle = 0;
  285. }
  286. }
  287. bool AHSpielVideo::ladeDaten( int spielId, int karteId )
  288. {
  289. if( dllHandle )
  290. reset();
  291. KartenLeser *reader = KartenLeser::getInstance();
  292. reader->lock();
  293. reader->setKarteId( karteId );
  294. Text *pfad = reader->getSpielPfad();
  295. if( !pfad )
  296. {
  297. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( reader->getLetzterFehler() ), new Text( "Ok" ) );
  298. reader->unlock();
  299. reader->release();
  300. return 0;
  301. }
  302. pfad->append( "bin/" );
  303. Text *spielArtName = reader->getSpielName();
  304. if( !spielArtName )
  305. {
  306. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( reader->getLetzterFehler() ), new Text( "Ok" ) );
  307. reader->unlock();
  308. reader->release();
  309. pfad->release();
  310. return 0;
  311. }
  312. pfad->append( spielArtName->getText() );
  313. pfad->append( ".dll" );
  314. reader->unlock();
  315. reader->release();
  316. dllName->setText( "Spiele/" );
  317. dllName->append( spielArtName->getText() );
  318. dllName->append( ".dll" );
  319. spielArtName->release();
  320. dllHandle = Framework::getDLLRegister()->ladeDLL( *dllName, *pfad );
  321. if( !dllHandle )
  322. {
  323. Text *msg = new Text( "Die DLL Datei '" );
  324. msg->append( pfad->getText() );
  325. msg->append( "' konnte nicht geladen werden." );
  326. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), msg, new Text( "Ok" ) );
  327. pfad->release();
  328. return 0;
  329. }
  330. AHSADLLStart startFunk = (AHSADLLStart)GetProcAddress( dllHandle, "GetAufzeichnung" );
  331. if( !startFunk )
  332. {
  333. if( dllHandle )
  334. {
  335. Framework::getDLLRegister()->releaseDLL( *dllName );
  336. dllHandle = 0;
  337. }
  338. Text *msg = new Text( "Die Funktion 'GetAufzeichnung' konnte in der DLL Datei '" );
  339. msg->append( pfad->getText() );
  340. msg->append( "' nicht gefunden werden." );
  341. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), msg, new Text( "Ok" ) );
  342. pfad->release();
  343. return 0;
  344. }
  345. pfad->release();
  346. video = startFunk();
  347. if( !video )
  348. {
  349. if( dllHandle )
  350. {
  351. Framework::getDLLRegister()->releaseDLL( *dllName );
  352. dllHandle = 0;
  353. }
  354. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Für diese Spielart ist keine Aufzeichnung verfügbar." ), new Text( "Ok" ) );
  355. return 0;
  356. }
  357. this->spielId = spielId;
  358. video->setSchrift( schrift->getThis() );
  359. video->setBildschirm( hauptScreen );
  360. start();
  361. return 1;
  362. }
  363. void AHSpielVideo::thread()
  364. {
  365. laden->setSichtbar( 1 );
  366. KSGClient::HistorieServerClient *historieClient = infoClient->createHistorieServerClient( spielId );
  367. if( !historieClient )
  368. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( "Die Daten für dieses Spiel können zur Zeit nicht abgerufen werden." ), new Text( "Ok" ) );
  369. else
  370. {
  371. if( !historieClient->downloadSpielHistorie() )
  372. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( historieClient->getLetzterFehler() ), new Text( "Ok" ) );
  373. historieClient->release();
  374. }
  375. video->ladeSpiel( spielId );
  376. laden->setSichtbar( 0 );
  377. if( sichtbar )
  378. {
  379. nachLogin->setSpielAufzeichnung( video->getThis() );
  380. aktion = 7; // Aufzeichnung betreten
  381. }
  382. run = 0;
  383. }
  384. void AHSpielVideo::setSichtbar( bool sichtbar )
  385. {
  386. if( !video )
  387. return;
  388. if( sichtbar && !run )
  389. {
  390. nachLogin->setSpielAufzeichnung( video->getThis() );
  391. aktion = 7; // Aufzeichnung betreten
  392. }
  393. this->sichtbar = sichtbar;
  394. if( sichtbar && !alpha )
  395. alpha = 1;
  396. }
  397. bool AHSpielVideo::tick( double tickVal )
  398. {
  399. if( !video || !alpha )
  400. return 0;
  401. if( video->hatVerlassen( 0 ) && sichtbar )
  402. setSichtbar( 0 );
  403. bool ret = laden->tick( tickVal );
  404. this->tickVal += tickVal * 150;
  405. int val = ( int )this->tickVal;
  406. this->tickVal -= val;
  407. if( val )
  408. {
  409. if( sichtbar && alpha != 255 )
  410. {
  411. if( alpha + val > 255 )
  412. alpha = 255;
  413. else
  414. alpha += (unsigned char)val;
  415. ret = 1;
  416. }
  417. if( !sichtbar && alpha )
  418. {
  419. if( alpha - val < 0 )
  420. alpha = 0;
  421. else
  422. alpha -= (unsigned char)val;
  423. ret = 1;
  424. }
  425. }
  426. return ret;
  427. }
  428. void AHSpielVideo::render( Bild &zRObj )
  429. {
  430. if( !video || !alpha )
  431. return;
  432. if( !zRObj.setDrawOptions( 0, 0, videoF->getBreite() + 10, videoF->getHeight() + 40 ) )
  433. return;
  434. zRObj.setAlpha( alpha );
  435. videoF->render( zRObj );
  436. laden->render( zRObj );
  437. zRObj.releaseAlpha();
  438. zRObj.releaseDrawOptions();
  439. }
  440. // constant
  441. bool AHSpielVideo::istNochSichtbar() const
  442. {
  443. return alpha != 0;
  444. }
  445. // löscht das objekt wenn es nicht mehr gebraucht wird und beendet den Thread
  446. Thread *AHSpielVideo::release()
  447. {
  448. if( ref == 2 && run )
  449. warteAufThread( INFINITE );
  450. return Thread::release();
  451. }
  452. // Inhalt der AHSLETeamListeSpieler Klasse aus AccountHistorie.h
  453. // Konstruktor
  454. AHSLETeamListeSpieler::AHSLETeamListeSpieler( Schrift *zSchrift, char *name, int punkte, char *status, int farbe, int br )
  455. : nameTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, name ) ),
  456. punkteTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Punkte: " ) += punkte ) ),
  457. statusTF( initTextFeld( 215, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, status ) ),
  458. ram( new LRahmen() ),
  459. ref( 1 )
  460. {
  461. TextRenderer tr( zSchrift->getThis() );
  462. tr.setSchriftSize( 12 );
  463. nameTF->setSize( tr.getTextBreite( nameTF->zText()->getText() ) + 5, 20 );
  464. punkteTF->setSize( tr.getTextBreite( punkteTF->zText()->getText() ) + 5, 20 );
  465. statusTF->setSize( tr.getTextBreite( statusTF->zText()->getText() ) + 5, 20 );
  466. if( nameTF->getBreite() > 100 )
  467. punkteTF->setPosition( 10 + nameTF->getBreite(), 0 );
  468. if( punkteTF->getX() + punkteTF->getBreite() > 210 )
  469. statusTF->setPosition( punkteTF->getX() + punkteTF->getBreite() + 5, 0 );
  470. ram->setFarbe( farbe );
  471. ram->setSize( br, 20 );
  472. ram->setRamenBreite( 1 );
  473. }
  474. // Destruktor
  475. AHSLETeamListeSpieler::~AHSLETeamListeSpieler()
  476. {
  477. nameTF->release();
  478. punkteTF->release();
  479. statusTF->release();
  480. ram->release();
  481. }
  482. // nicht constant
  483. void AHSLETeamListeSpieler::render( int yOff, Bild &zRObj )
  484. {
  485. if( !zRObj.setDrawOptions( 2, yOff, ram->getBreite(), ram->getHeight() ) )
  486. return;
  487. nameTF->render( zRObj );
  488. punkteTF->render( zRObj );
  489. statusTF->render( zRObj );
  490. ram->render( zRObj );
  491. zRObj.releaseDrawOptions();
  492. }
  493. // cnstant
  494. // Reference Counting
  495. AHSLETeamListeSpieler *AHSLETeamListeSpieler::getThis()
  496. {
  497. ref++;
  498. return this;
  499. }
  500. AHSLETeamListeSpieler *AHSLETeamListeSpieler::release()
  501. {
  502. ref--;
  503. if( !ref )
  504. delete this;
  505. return 0;
  506. }
  507. // Inhalt der AHSLETeamListeTeam Klasse aus AccountHistorie.h
  508. // Konstruktor
  509. AHSLETeamListeTeam::AHSLETeamListeTeam( Schrift *zSchrift, char *name, int sAnz, char *status, int farbe, int br )
  510. : nameTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, name ) ),
  511. sAnzahlTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Spieleranzahl: " ) += sAnz ) ),
  512. statusTF( initTextFeld( 215, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, status ) ),
  513. ram( new LRahmen() ),
  514. members( new RCArray< AHSLETeamListeSpieler >() ),
  515. ref( 1 )
  516. {
  517. TextRenderer tr( zSchrift->getThis() );
  518. tr.setSchriftSize( 12 );
  519. nameTF->setSize( tr.getTextBreite( nameTF->zText()->getText() ) + 5, 20 );
  520. sAnzahlTF->setSize( tr.getTextBreite( sAnzahlTF->zText()->getText() ) + 5, 20 );
  521. statusTF->setSize( tr.getTextBreite( statusTF->zText()->getText() ) + 5, 20 );
  522. if( nameTF->getBreite() > 100 )
  523. sAnzahlTF->setPosition( 10 + nameTF->getBreite(), 0 );
  524. if( sAnzahlTF->getX() + sAnzahlTF->getBreite() > 210 )
  525. statusTF->setPosition( sAnzahlTF->getX() + sAnzahlTF->getBreite() + 5, 0 );
  526. ram->setFarbe( farbe );
  527. ram->setSize( br, 20 );
  528. ram->setRamenBreite( 1 );
  529. }
  530. // Destruktor
  531. AHSLETeamListeTeam::~AHSLETeamListeTeam()
  532. {
  533. nameTF->release();
  534. sAnzahlTF->release();
  535. statusTF->release();
  536. ram->release();
  537. members->release();
  538. }
  539. // nicht constant
  540. void AHSLETeamListeTeam::addSpieler( AHSLETeamListeSpieler *s )
  541. {
  542. members->add( s );
  543. int maxHö = 20;
  544. int anz = members->getEintragAnzahl();
  545. if( anz )
  546. maxHö += 4 + 20 * anz;
  547. ram->setSize( ram->getBreite(), maxHö );
  548. }
  549. void AHSLETeamListeTeam::render( int xOff, int yOff, Bild &zRObj )
  550. {
  551. if( !zRObj.setDrawOptions( xOff, yOff, ram->getBreite(), ram->getHeight() ) )
  552. return;
  553. nameTF->render( zRObj );
  554. sAnzahlTF->render( zRObj );
  555. statusTF->render( zRObj );
  556. ram->render( zRObj );
  557. yOff = 22;
  558. int anz = members->getEintragAnzahl();
  559. for( int i = 0; i < anz; i++ )
  560. {
  561. members->z( i )->render( yOff, zRObj );
  562. yOff += 20;
  563. }
  564. zRObj.releaseDrawOptions();
  565. }
  566. // constant
  567. int AHSLETeamListeTeam::getHeight() const
  568. {
  569. return ram->getHeight();
  570. }
  571. // Reference Counting
  572. AHSLETeamListeTeam *AHSLETeamListeTeam::getThis()
  573. {
  574. ref++;
  575. return this;
  576. }
  577. AHSLETeamListeTeam *AHSLETeamListeTeam::release()
  578. {
  579. ref--;
  580. if( !ref )
  581. delete this;
  582. return 0;
  583. }
  584. // Inhalt der AHSLETeamListe Klasse aus AccountHistorie.h
  585. // Konstruktor
  586. AHSLETeamListe::AHSLETeamListe( int xPos )
  587. : members( new RCArray< AHSLETeamListeTeam >() ),
  588. xPos( xPos ),
  589. ref( 1 )
  590. {
  591. }
  592. // Destruktor
  593. AHSLETeamListe::~AHSLETeamListe()
  594. {
  595. members->release();
  596. }
  597. // nicht constant
  598. void AHSLETeamListe::addTeam( AHSLETeamListeTeam *t )
  599. {
  600. members->add( t );
  601. }
  602. void AHSLETeamListe::render( Bild &zRObj )
  603. {
  604. int y = 25;
  605. int anz = members->getEintragAnzahl();
  606. for( int i = 0; i < anz; i++ )
  607. {
  608. members->z( i )->render( xPos, y, zRObj );
  609. y += members->z( i )->getHeight();
  610. }
  611. }
  612. // constant
  613. int AHSLETeamListe::getHeight() const
  614. {
  615. int anz = members->getEintragAnzahl();
  616. int hö = 0;
  617. for( int i = 0; i < anz; i++ )
  618. hö += members->z( i )->getHeight();
  619. return hö;
  620. }
  621. int AHSLETeamListe::getBreite() const
  622. {
  623. return 730 - xPos;
  624. }
  625. // Reference Counting
  626. AHSLETeamListe *AHSLETeamListe::getThis()
  627. {
  628. ref++;
  629. return this;
  630. }
  631. AHSLETeamListe *AHSLETeamListe::release()
  632. {
  633. ref--;
  634. if( !ref )
  635. delete this;
  636. return 0;
  637. }
  638. // Inhalt der AHSpielListeEintrag Klasse aus AccountHistorie.h
  639. // Konstruktor
  640. AHSpielListeEintrag::AHSpielListeEintrag( int id, int karteId, Schrift *zSchrift, char *spiel, char *karte, char *datum, char *status,
  641. char *dauer, char *spielStatus, char *gewinner, int sAnzahl )
  642. : spielTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Spiel: " ) += spiel ) ),
  643. karteTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Karte: " ) += karte ) ),
  644. datumTF( initTextFeld( 215, 0, 180, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Datum: " ) += datum ) ),
  645. statusTF( initTextFeld( 400, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Status: " ) += status ) ),
  646. spiel( new Text( spiel ) ),
  647. karte( new Text( karte ) ),
  648. datum( new Text( datum ) ),
  649. status( new Text( status ) ),
  650. detailsK( initKnopf( 715, 0, 20, 20, 0, 0, "" ) ),
  651. dauerTF( initTextFeld( 5, 25, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Dauer: " ) += dauer ) ),
  652. spielStatusTF( initTextFeld( 5, 45, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Status: " ) += spielStatus ) ),
  653. gewinnerTF( initTextFeld( 5, 65, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Gewinner: " ) += gewinner ) ),
  654. sAnzahlTF( initTextFeld( 5, 85, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Spieleranzahl: " ) += sAnzahl ) ),
  655. statistikK( initKnopf( 5, 105, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Statistik" ) ),
  656. videoK( initKnopf( 5, 130, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Aufzeichnung" ) ),
  657. liste( 0 ),
  658. ram( new LRahmen() ),
  659. ausklappen( bilder->get( "data/client/bilder/account.ltdb/ausklappen.png" ) ),
  660. einklappen( bilder->get( "data/client/bilder/account.ltdb/einklappen.png" ) ),
  661. id( id ),
  662. karteId( karteId ),
  663. tickVal( 0 ),
  664. aktion( 0 ),
  665. maxHö( 155 ),
  666. ref( 1 )
  667. {
  668. detailsK->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  669. detailsK->setHintergrundBildZ( ausklappen->getThis() );
  670. initToolTip( detailsK, "Details anzeigen.", zSchrift, hauptScreen );
  671. TextRenderer tr( zSchrift->getThis() );
  672. tr.setSchriftSize( 12 );
  673. spielTF->setSize( tr.getTextBreite( spielTF->zText()->getText() ) + 5, 20 );
  674. karteTF->setSize( tr.getTextBreite( karteTF->zText()->getText() ) + 5, 20 );
  675. datumTF->setSize( tr.getTextBreite( datumTF->zText()->getText() ) + 5, 20 );
  676. statusTF->setSize( tr.getTextBreite( statusTF->zText()->getText() ) + 5, 20 );
  677. dauerTF->setSize( tr.getTextBreite( dauerTF->zText()->getText() ), 20 );
  678. spielStatusTF->setSize( tr.getTextBreite( spielStatusTF->zText()->getText() ), 20 );
  679. gewinnerTF->setSize( tr.getTextBreite( gewinnerTF->zText()->getText() ), 20 );
  680. sAnzahlTF->setSize( tr.getTextBreite( sAnzahlTF->zText()->getText() ), 20 );
  681. if( spielTF->getBreite() > 100 )
  682. karteTF->setPosition( 10 + spielTF->getBreite(), 0 );
  683. if( karteTF->getX() + karteTF->getBreite() > 210 )
  684. datumTF->setPosition( karteTF->getX() + karteTF->getBreite() + 5, 0 );
  685. if( datumTF->getX() + datumTF->getBreite() > 395 )
  686. statusTF->setPosition( datumTF->getX() + datumTF->getBreite() + 5, 0 );
  687. ram->setFarbe( 0xFFFFFFFF );
  688. ram->setSize( 735, 20 );
  689. ram->setRamenBreite( 1 );
  690. int br = dauerTF->getBreite();
  691. br = br > spielStatusTF->getBreite() ? br : spielStatusTF->getBreite();
  692. br = br > gewinnerTF->getBreite() ? br : gewinnerTF->getBreite();
  693. br = br > sAnzahlTF->getBreite() ? br : sAnzahlTF->getBreite();
  694. statistikK->setSize( br, statistikK->getHeight() );
  695. videoK->setSize( br, videoK->getHeight() );
  696. liste = new AHSLETeamListe( br + 10 );
  697. }
  698. // Destruktor
  699. AHSpielListeEintrag::~AHSpielListeEintrag()
  700. {
  701. spielTF->release();
  702. karteTF->release();
  703. datumTF->release();
  704. statusTF->release();
  705. spiel->release();
  706. karte->release();
  707. datum->release();
  708. status->release();
  709. detailsK->release();
  710. dauerTF->release();
  711. spielStatusTF->release();
  712. gewinnerTF->release();
  713. sAnzahlTF->release();
  714. statistikK->release();
  715. videoK->release();
  716. liste->release();
  717. ram->release();
  718. einklappen->release();
  719. ausklappen->release();
  720. }
  721. // nicht constant
  722. void AHSpielListeEintrag::addTeam( AHSLETeamListeTeam *t )
  723. {
  724. liste->addTeam( t );
  725. maxHö = liste->getHeight();
  726. maxHö = 155 > maxHö + 30 ? 155 : maxHö + 30;
  727. }
  728. bool AHSpielListeEintrag::tick( double tickVal )
  729. {
  730. bool ret = detailsK->tick( tickVal );
  731. ret |= statistikK->tick( tickVal );
  732. ret |= videoK->tick( tickVal );
  733. this->tickVal += tickVal * 150;
  734. int val = ( int )this->tickVal;
  735. this->tickVal -= val;
  736. if( val )
  737. {
  738. if( detailsK->zHintergrundBild() == ausklappen && ram->getHeight() != 20 )
  739. {
  740. if( ram->getHeight() - val < 20 )
  741. ram->setSize( ram->getBreite(), 20 );
  742. else
  743. ram->setSize( ram->getBreite(), ram->getHeight() - val );
  744. ret = 1;
  745. }
  746. if( detailsK->zHintergrundBild() == einklappen )
  747. {
  748. if( ram->getHeight() > maxHö )
  749. {
  750. if( ram->getHeight() - val < maxHö )
  751. ram->setSize( ram->getBreite(), maxHö );
  752. else
  753. ram->setSize( ram->getBreite(), ram->getHeight() - val );
  754. ret = 1;
  755. }
  756. if( ram->getHeight() < maxHö )
  757. {
  758. if( ram->getHeight() + val > maxHö )
  759. ram->setSize( ram->getBreite(), maxHö );
  760. else
  761. ram->setSize( ram->getBreite(), ram->getHeight() + val );
  762. ret = 1;
  763. }
  764. }
  765. }
  766. return ret;
  767. }
  768. void AHSpielListeEintrag::doMausEreignis( MausEreignis &me )
  769. {
  770. bool meVera = 0;
  771. bool meVeraTmp = 0;
  772. if( me.mx < 0 || me.my < 0 || me.mx >= ram->getBreite() || me.my >= ram->getHeight() )
  773. {
  774. meVeraTmp = me.verarbeitet;
  775. me.verarbeitet = 1;
  776. meVera = 1;
  777. }
  778. int vera = me.verarbeitet;
  779. detailsK->doMausEreignis( me );
  780. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  781. {
  782. if( detailsK->zHintergrundBild() == einklappen )
  783. detailsK->setHintergrundBildZ( ausklappen->getThis() );
  784. else
  785. detailsK->setHintergrundBildZ( einklappen->getThis() );
  786. }
  787. vera = me.verarbeitet;
  788. statistikK->doMausEreignis( me );
  789. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  790. aktion = 1;
  791. vera = me.verarbeitet;
  792. videoK->doMausEreignis( me );
  793. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  794. aktion = 2;
  795. if( meVera )
  796. me.verarbeitet = meVeraTmp;
  797. }
  798. void AHSpielListeEintrag::render( int yOff, Bild &zRObj )
  799. {
  800. if( !zRObj.setDrawOptions( 5, yOff, ram->getBreite(), ram->getHeight() ) )
  801. return;
  802. ram->render( zRObj );
  803. if( ram->getHeight() > 20 )
  804. zRObj.drawLinieH( 1, 20, ram->getBreite() - 2, ram->getFarbe() );
  805. if( !zRObj.setDrawOptions( 1, 1, ram->getBreite() - 2, ram->getHeight() - 2 ) )
  806. {
  807. zRObj.releaseDrawOptions();
  808. return;
  809. }
  810. spielTF->render( zRObj );
  811. karteTF->render( zRObj );
  812. datumTF->render( zRObj );
  813. statusTF->render( zRObj );
  814. detailsK->render( zRObj );
  815. dauerTF->render( zRObj );
  816. spielStatusTF->render( zRObj );
  817. gewinnerTF->render( zRObj );
  818. sAnzahlTF->render( zRObj );
  819. statistikK->render( zRObj );
  820. videoK->render( zRObj );
  821. liste->render( zRObj );
  822. zRObj.releaseDrawOptions();
  823. zRObj.releaseDrawOptions();
  824. }
  825. int AHSpielListeEintrag::getAktion()
  826. {
  827. int ret = aktion;
  828. aktion = 0;
  829. return ret;
  830. }
  831. // constant
  832. int AHSpielListeEintrag::getKarteId() const
  833. {
  834. return karteId;
  835. }
  836. int AHSpielListeEintrag::getHeight() const
  837. {
  838. return ram->getHeight();
  839. }
  840. int AHSpielListeEintrag::getId() const
  841. {
  842. return id;
  843. }
  844. int AHSpielListeEintrag::getListeBreite() const
  845. {
  846. return liste->getBreite();
  847. }
  848. Text *AHSpielListeEintrag::zSpiel() const
  849. {
  850. return spiel;
  851. }
  852. Text *AHSpielListeEintrag::zKarte() const
  853. {
  854. return karte;
  855. }
  856. Text *AHSpielListeEintrag::zDatum() const
  857. {
  858. return datum;
  859. }
  860. Text *AHSpielListeEintrag::zStatus() const
  861. {
  862. return status;
  863. }
  864. // Reference Counting
  865. AHSpielListeEintrag *AHSpielListeEintrag::getThis()
  866. {
  867. ref++;
  868. return this;
  869. }
  870. AHSpielListeEintrag *AHSpielListeEintrag::release()
  871. {
  872. ref--;
  873. if( !ref )
  874. delete this;
  875. return 0;
  876. }
  877. // Inhalt der AHSpielListe Klasse aus AccountHistorie.h
  878. // Konstruktor
  879. AHSpielListe::AHSpielListe()
  880. : Zeichnung(),
  881. ram( new LRahmen() ),
  882. scroll( new VScrollBar() ),
  883. members( new RCArray< AHSpielListeEintrag >() ),
  884. sortSpalte( new Text( "Spiel" ) ),
  885. sortAbsteigend( 0 )
  886. {
  887. pos = Punkt( 10, 40 );
  888. ram->setFarbe( 0xFFFFFFFF );
  889. ram->setRamenBreite( 1 );
  890. ram->setSize( 760, 380 );
  891. scroll->update( 0, 380 );
  892. }
  893. // Destruktor
  894. AHSpielListe::~AHSpielListe()
  895. {
  896. ram->release();
  897. scroll->release();
  898. members->release();
  899. sortSpalte->release();
  900. }
  901. // privat
  902. int AHSpielListe::getReihenfolge( int *arr )
  903. {
  904. lockZeichnung();
  905. int anz = members->getEintragAnzahl();
  906. if( !anz )
  907. {
  908. unlockZeichnung();
  909. return 0;
  910. }
  911. int ret = 0;
  912. bool *fertig = new bool[ anz ];
  913. ZeroMemory( fertig, anz );
  914. for( int i = 0; i < anz; i++ )
  915. {
  916. int index = -1;
  917. Text minMaxT;
  918. Zeit minMaxZ;
  919. for( int j = 0; j < anz; j++ )
  920. {
  921. AHSpielListeEintrag *tmp = members->z( j );
  922. if( sortSpalte->istGleich( "Spiel" ) && !fertig[ j ] && ( index < 0 ||
  923. ( sortAbsteigend && *tmp->zSpiel() > minMaxT ) || ( !sortAbsteigend && *tmp->zSpiel() < minMaxT ) ) )
  924. {
  925. minMaxT = tmp->zSpiel()->getText();
  926. index = j;
  927. }
  928. else if( sortSpalte->istGleich( "Karte" ) && !fertig[ j ] && ( index < 0 ||
  929. ( sortAbsteigend && *tmp->zKarte() > minMaxT ) || ( !sortAbsteigend && *tmp->zKarte() < minMaxT ) ) )
  930. {
  931. minMaxT = tmp->zKarte()->getText();
  932. index = j;
  933. }
  934. else if( sortSpalte->istGleich( "Datum" ) && !fertig[ j ] && ( index < 0 ||
  935. ( sortAbsteigend && minMaxZ.istKleiner( "y-m-d h:i", tmp->zDatum()->getText() ) ) ||
  936. ( !sortAbsteigend && minMaxZ.istLater( "y-m-d h:i", tmp->zDatum()->getText() ) ) ) )
  937. {
  938. minMaxZ.setZeit( "y-m-d h:i", tmp->zDatum()->getText() );
  939. index = j;
  940. }
  941. else if( sortSpalte->istGleich( "Status" ) && !fertig[ j ] && ( index < 0 ||
  942. ( sortAbsteigend && *tmp->zStatus() > minMaxT ) || ( !sortAbsteigend && *tmp->zStatus() < minMaxT ) ) )
  943. {
  944. minMaxT = tmp->zStatus()->getText();
  945. index = j;
  946. }
  947. }
  948. if( index < 0 )
  949. break;
  950. fertig[ index ] = 1;
  951. arr[ ret ] = index;
  952. ret++;
  953. }
  954. delete[] fertig;
  955. unlockZeichnung();
  956. return ret;
  957. }
  958. // nicht constant
  959. void AHSpielListe::setSortSpalte( char *sp )
  960. {
  961. lockZeichnung();
  962. sortSpalte->setText( sp );
  963. unlockZeichnung();
  964. }
  965. void AHSpielListe::setSortRichtung( bool absteigend )
  966. {
  967. sortAbsteigend = absteigend;
  968. }
  969. void AHSpielListe::reset()
  970. {
  971. lockZeichnung();
  972. members->leeren();
  973. unlockZeichnung();
  974. }
  975. void AHSpielListe::addSpiel( AHSpielListeEintrag *s )
  976. {
  977. lockZeichnung();
  978. members->add( s );
  979. unlockZeichnung();
  980. }
  981. bool AHSpielListe::tick( double tickVal )
  982. {
  983. bool ret = scroll->getRend();
  984. lockZeichnung();
  985. int anz = members->getEintragAnzahl();
  986. for( int i = 0; i < anz; i++ )
  987. ret |= members->z( i )->tick( tickVal );
  988. unlockZeichnung();
  989. return ret;
  990. }
  991. void AHSpielListe::doMausEreignis( MausEreignis &me )
  992. {
  993. bool vera = 0;
  994. if( me.mx - pos.x <= 0 || me.mx - pos.x >= ram->getBreite() || me.my - pos.y <= 0 || me.my - pos.y >= ram->getHeight() )
  995. {
  996. vera = 1;
  997. me.verarbeitet = 1;
  998. }
  999. int mx = me.mx, my = me.my;
  1000. me.mx -= pos.x;
  1001. me.my -= pos.y;
  1002. scroll->doMausMessage( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, me );
  1003. me.mx -= 5;
  1004. me.my -= 5 - scroll->getScroll();
  1005. lockZeichnung();
  1006. int anz = members->getEintragAnzahl();
  1007. int *rf = new int[ anz ];
  1008. int rfAnz = getReihenfolge( rf );
  1009. for( int i = 0; i < rfAnz; i++ )
  1010. {
  1011. members->z( rf[ i ] )->doMausEreignis( me );
  1012. me.my -= members->z( rf[ i ] )->getHeight() + 5;
  1013. }
  1014. delete[] rf;
  1015. unlockZeichnung();
  1016. me.mx = mx, me.my = my;
  1017. if( vera )
  1018. me.verarbeitet = 0;
  1019. }
  1020. void AHSpielListe::render( Bild &zRObj )
  1021. {
  1022. if( !zRObj.setDrawOptions( pos, ram->getSize() ) )
  1023. return;
  1024. ram->render( zRObj );
  1025. scroll->render( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, zRObj );
  1026. if( !zRObj.setDrawOptions( 1, 1, ram->getBreite() - 15, ram->getHeight() - 2 ) )
  1027. {
  1028. zRObj.releaseDrawOptions();
  1029. return;
  1030. }
  1031. int anzHö = 5;
  1032. lockZeichnung();
  1033. int anz = members->getEintragAnzahl();
  1034. int *rf = new int[ anz ];
  1035. int rfAnz = getReihenfolge( rf );
  1036. for( int i = 0; i < rfAnz; i++ )
  1037. {
  1038. members->z( rf[ i ] )->render( anzHö - scroll->getScroll(), zRObj );
  1039. anzHö += members->z( rf[ i ] )->getHeight() + 5;
  1040. }
  1041. delete[] rf;
  1042. unlockZeichnung();
  1043. scroll->update( anzHö, ram->getHeight() - 2 );
  1044. zRObj.releaseDrawOptions();
  1045. zRObj.releaseDrawOptions();
  1046. }
  1047. // constant
  1048. int AHSpielListe::getAktion( int *spielId, int *karteId ) const
  1049. {
  1050. int anz = members->getEintragAnzahl();
  1051. for( int i = 0; i < anz; i++ )
  1052. {
  1053. int ak = members->z( i )->getAktion();
  1054. if( ak )
  1055. {
  1056. *spielId = members->z( i )->getId();
  1057. *karteId = members->z( i )->getKarteId();
  1058. return ak;
  1059. }
  1060. }
  1061. return 0;
  1062. }
  1063. // Inhalt der AccountHistorie Klasse aus AccountHistorie.h
  1064. // Konstruktor
  1065. AccountHistorie::AccountHistorie( Schrift *zSchrift )
  1066. : Thread(),
  1067. schrift( zSchrift->getThis() ),
  1068. historieF( initFenster( 810, 40, 780, 450, zSchrift, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Rahmen | Fenster::Style::Erlaubt, "Historie von " ) ),
  1069. sortSpalte( initAuswahlBox( 10, 10, 150, 20, zSchrift, ABSTYLE, { "Spiel", "Karte", "Datum", "Status" } ) ),
  1070. sortRichtung( initAuswahlBox( 170, 10, 150, 20, zSchrift, ABSTYLE, { "Aufwärts", "Abwärts" } ) ),
  1071. liste( new AHSpielListe() ),
  1072. statistik( new AHSpielStatistik( zSchrift->getThis() ) ),
  1073. video( new AHSpielVideo( zSchrift->getThis() ) ),
  1074. status( 0 ),
  1075. accId( 0 ),
  1076. animation( 0 ),
  1077. alpha( 255 ),
  1078. alpha2( 255 ),
  1079. alpha3( 255 ),
  1080. tickVal( 0 ),
  1081. rend( 0 )
  1082. {
  1083. initToolTip( sortSpalte, "Wähle aus, nach welcher Spalte die\nTabelle sortiert werden soll.", zSchrift, hauptScreen );
  1084. initToolTip( sortRichtung, "Wähle aus, ob Aufwärts oder Abwärts\nsortiert werden soll.", zSchrift, hauptScreen );
  1085. historieF->addMember( liste->getThis() );
  1086. historieF->addMember( sortSpalte->getThis() );
  1087. historieF->addMember( sortRichtung->getThis() );
  1088. historieF->setMausEreignis( _ret1ME );
  1089. }
  1090. // Destruktor
  1091. AccountHistorie::~AccountHistorie()
  1092. {
  1093. schrift->release();
  1094. historieF->release();
  1095. sortSpalte->release();
  1096. sortRichtung->release();
  1097. statistik->release();
  1098. liste->release();
  1099. video->release();
  1100. }
  1101. // nicht constant
  1102. void AccountHistorie::reset()
  1103. {
  1104. liste->reset();
  1105. statistik->reset();
  1106. video->reset();
  1107. }
  1108. void AccountHistorie::ladeStatistik( int accId )
  1109. {
  1110. if( this->accId == accId )
  1111. return;
  1112. this->status = 0;
  1113. if( run )
  1114. {
  1115. warteAufThread( 1000 );
  1116. ende();
  1117. }
  1118. if( ( animation | 0x1 ) == animation )
  1119. {
  1120. animation |= 0x4;
  1121. this->accId = accId;
  1122. this->status = 1;
  1123. return;
  1124. }
  1125. if( this->accId )
  1126. reset();
  1127. this->accId = accId;
  1128. start();
  1129. this->status = 1;
  1130. }
  1131. void AccountHistorie::thread()
  1132. {
  1133. Text *name = infoClient->getSpielerName( accId );
  1134. if( name )
  1135. {
  1136. name->insert( 0, "Historie von " );
  1137. historieF->setTitel( *name );
  1138. name->release();
  1139. }
  1140. Array< KSGClient::SpielHistorieDaten > *daten = infoClient->getSpielHistorieDaten( accId );
  1141. int anz = daten->getEintragAnzahl();
  1142. for( int i = 0; i < anz; i++ )
  1143. {
  1144. KSGClient::SpielHistorieDaten spiel = daten->get( i );
  1145. AHSpielListeEintrag *spielE = new AHSpielListeEintrag( spiel.id, spiel.karteId, schrift, spiel.spiel, spiel.karte,
  1146. spiel.datum, spiel.status, spiel.dauer,
  1147. spiel.spielStatus, spiel.gewinner, spiel.sAnzahl );
  1148. int tAnz = spiel.teams.getEintragAnzahl();
  1149. for( int j = 0; j < tAnz; j++ )
  1150. {
  1151. KSGClient::SpielHistorieTeamDaten team = spiel.teams.get( j );
  1152. AHSLETeamListeTeam *teamE = new AHSLETeamListeTeam( schrift, team.name, team.sAnzahl, team.status,
  1153. team.farbe, spielE->getListeBreite() );
  1154. int sAnz = team.spieler.getEintragAnzahl();
  1155. for( int k = 0; k < sAnz; k++ )
  1156. {
  1157. KSGClient::SpielHistorieSpielerDaten spieler = team.spieler.get( k );
  1158. AHSLETeamListeSpieler *spielerE = new AHSLETeamListeSpieler( schrift, spieler.name, spieler.punkte, spieler.status,
  1159. spieler.farbe, spielE->getListeBreite() - 4 );
  1160. teamE->addSpieler( spielerE );
  1161. }
  1162. spielE->addTeam( teamE );
  1163. }
  1164. liste->addSpiel( spielE );
  1165. }
  1166. daten->release();
  1167. animation &= ~0x4;
  1168. status = 2;
  1169. run = 0;
  1170. }
  1171. void AccountHistorie::setSichtbar( bool sichtbar, bool nachRechts )
  1172. {
  1173. if( sichtbar )
  1174. {
  1175. if( ( animation | 0x1 ) != animation || ( ( nachRechts && ( animation | 0x2 ) != animation ) || !nachRechts && ( animation | 0x2 ) == animation ) )
  1176. {
  1177. if( nachRechts )
  1178. historieF->setPosition( -810, 40 );
  1179. else
  1180. historieF->setPosition( 810, 40 );
  1181. }
  1182. animation |= 0x1;
  1183. }
  1184. else
  1185. animation &= ~0x1;
  1186. if( nachRechts )
  1187. animation |= 0x2;
  1188. else
  1189. animation &= ~0x2;
  1190. }
  1191. bool AccountHistorie::tick( double zeit )
  1192. {
  1193. if( !statistik->istNochSichtbar() && !video->istNochSichtbar() )
  1194. rend |= historieF->tick( zeit );
  1195. rend |= statistik->tick( zeit );
  1196. rend |= video->tick( zeit );
  1197. tickVal += zeit;
  1198. int valA = (int)( tickVal * 150 );
  1199. int valB = (int)( tickVal * 500 );
  1200. tickVal -= valA / 150.0;
  1201. if( valA )
  1202. {
  1203. if( ( animation | 0x8 ) == animation && alpha2 )
  1204. {
  1205. if( alpha2 - valA <= 0 )
  1206. {
  1207. alpha2 = 0;
  1208. statistik->setSichtbar( 1 );
  1209. }
  1210. else
  1211. alpha2 -= valA;
  1212. rend = 1;
  1213. }
  1214. if( ( animation | 0x8 ) != animation && alpha2 != 255 )
  1215. {
  1216. if( alpha2 + valA >= 255 )
  1217. alpha2 = 255;
  1218. else
  1219. alpha2 += valA;
  1220. rend = 1;
  1221. }
  1222. if( ( animation | 0x10 ) == animation && alpha3 )
  1223. {
  1224. if( alpha3 - valA <= 0 )
  1225. {
  1226. alpha3 = 0;
  1227. video->setSichtbar( 1 );
  1228. }
  1229. else
  1230. alpha3 -= valA;
  1231. rend = 1;
  1232. }
  1233. if( ( animation | 0x10 ) != animation && alpha3 != 255 )
  1234. {
  1235. if( alpha3 + valA >= 255 )
  1236. alpha3 = 255;
  1237. else
  1238. alpha3 += valA;
  1239. rend = 1;
  1240. }
  1241. if( ( animation | 0x4 ) == animation && alpha )
  1242. {
  1243. if( alpha - valA <= 0 )
  1244. alpha = 0;
  1245. else
  1246. alpha -= valA;
  1247. rend = 1;
  1248. if( !alpha )
  1249. {
  1250. reset();
  1251. start();
  1252. }
  1253. }
  1254. if( ( animation | 0x4 ) != animation && alpha != 255 )
  1255. {
  1256. if( alpha + valA >= 255 )
  1257. alpha = 255;
  1258. else
  1259. alpha += valA;
  1260. rend = 1;
  1261. }
  1262. }
  1263. if( valB )
  1264. {
  1265. if( ( animation | 0x1 ) == animation )
  1266. { // Sichtbar
  1267. if( ( animation | 0x2 ) == animation )
  1268. { // Nach Rechts
  1269. if( historieF->getX() != 10 )
  1270. {
  1271. if( historieF->getX() + valB > 10 )
  1272. historieF->setPosition( 10, historieF->getY() );
  1273. else
  1274. historieF->setPosition( historieF->getX() + valB, historieF->getY() );
  1275. statistik->setPosition( historieF->getX(), historieF->getY() );
  1276. rend = 1;
  1277. }
  1278. }
  1279. else
  1280. { // Nach Links
  1281. if( historieF->getX() != 10 )
  1282. {
  1283. if( historieF->getX() - valB < 10 )
  1284. historieF->setPosition( 10, historieF->getY() );
  1285. else
  1286. historieF->setPosition( historieF->getX() - valB, historieF->getY() );
  1287. statistik->setPosition( historieF->getX(), historieF->getY() );
  1288. rend = 1;
  1289. }
  1290. }
  1291. }
  1292. else
  1293. { // Unsichtbar
  1294. if( ( animation | 0x2 ) == animation )
  1295. { // Nach Rechts
  1296. if( historieF->getX() != 810 )
  1297. {
  1298. if( historieF->getX() + valB > 810 )
  1299. historieF->setPosition( 810, historieF->getY() );
  1300. else
  1301. historieF->setPosition( historieF->getX() + valB, historieF->getY() );
  1302. statistik->setPosition( historieF->getX(), historieF->getY() );
  1303. rend = 1;
  1304. }
  1305. }
  1306. else
  1307. { // Nach Links
  1308. if( historieF->getX() != -810 )
  1309. {
  1310. if( historieF->getX() - valB < -810 )
  1311. historieF->setPosition( -810, historieF->getY() );
  1312. else
  1313. historieF->setPosition( historieF->getX() - valB, historieF->getY() );
  1314. statistik->setPosition( historieF->getX(), historieF->getY() );
  1315. rend = 1;
  1316. }
  1317. }
  1318. }
  1319. }
  1320. if( !alpha2 && !statistik->istNochSichtbar() )
  1321. {
  1322. animation &= ~0x8;
  1323. statistik->reset();
  1324. }
  1325. if( !alpha3 && !video->istNochSichtbar() )
  1326. {
  1327. animation &= ~0x10;
  1328. video->reset();
  1329. }
  1330. bool ret = rend;
  1331. rend = 0;
  1332. return ret;
  1333. }
  1334. void AccountHistorie::doMausEreignis( MausEreignis &me )
  1335. {
  1336. if( !statistik->istNochSichtbar() && !video->istNochSichtbar() && alpha == 255 && alpha2 == 255 && alpha3 == 255 )
  1337. {
  1338. int sortSpalteS = sortSpalte->getAuswahl();
  1339. int sortRichtungS = sortRichtung->getAuswahl();
  1340. historieF->doMausEreignis( me );
  1341. if( sortSpalte->getAuswahl() != sortSpalteS )
  1342. {
  1343. liste->setSortSpalte( sortSpalte->zEintrag( sortSpalte->getAuswahl() )->zText()->getText() );
  1344. sortSpalte->einklappen();
  1345. }
  1346. if( sortRichtung->getAuswahl() != sortRichtungS )
  1347. {
  1348. liste->setSortRichtung( sortRichtung->getAuswahl() != 0 );
  1349. sortRichtung->einklappen();
  1350. }
  1351. int spielId = 0;
  1352. int karteId = 0;
  1353. int ak = liste->getAktion( &spielId, &karteId );
  1354. if( ak == 1 )
  1355. { // Statistik anzeigen
  1356. if( statistik->ladeDaten( spielId, karteId ) )
  1357. animation |= 0x8;
  1358. }
  1359. if( ak == 2 )
  1360. { // Aufzeichnung abspielen
  1361. if( video->ladeDaten( spielId, karteId ) )
  1362. animation |= 0x10;
  1363. }
  1364. }
  1365. if( statistik->istNochSichtbar() )
  1366. statistik->doMausEreignis( me );
  1367. }
  1368. void AccountHistorie::doTastaturEreignis( TastaturEreignis &te )
  1369. {
  1370. if( statistik->istNochSichtbar() )
  1371. statistik->doTastaturEreignis( te );
  1372. }
  1373. void AccountHistorie::render( Bild &zRObj )
  1374. {
  1375. zRObj.setAlpha( alpha );
  1376. if( alpha2 && alpha3 )
  1377. {
  1378. zRObj.setAlpha( alpha2 );
  1379. zRObj.setAlpha( alpha3 );
  1380. historieF->render( zRObj );
  1381. zRObj.releaseAlpha();
  1382. zRObj.releaseAlpha();
  1383. }
  1384. if( statistik->istNochSichtbar() )
  1385. statistik->render( zRObj );
  1386. if( video->istNochSichtbar() )
  1387. video->render( zRObj );
  1388. zRObj.releaseAlpha();
  1389. }
  1390. // constant
  1391. int AccountHistorie::getStatus() const
  1392. {
  1393. return status;
  1394. }