AccountHistorie.cpp 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480
  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->downloadSpielHistorie() )
  368. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ), new Text( historieClient->getLetzterFehler() ), new Text( "Ok" ) );
  369. historieClient->release();
  370. video->ladeSpiel( spielId );
  371. laden->setSichtbar( 0 );
  372. if( sichtbar )
  373. {
  374. nachLogin->setSpielAufzeichnung( video->getThis() );
  375. aktion = 7; // Aufzeichnung betreten
  376. }
  377. run = 0;
  378. }
  379. void AHSpielVideo::setSichtbar( bool sichtbar )
  380. {
  381. if( !video )
  382. return;
  383. if( sichtbar && !run )
  384. {
  385. nachLogin->setSpielAufzeichnung( video->getThis() );
  386. aktion = 7; // Aufzeichnung betreten
  387. }
  388. this->sichtbar = sichtbar;
  389. if( sichtbar && !alpha )
  390. alpha = 1;
  391. }
  392. bool AHSpielVideo::tick( double tickVal )
  393. {
  394. if( !video || !alpha )
  395. return 0;
  396. if( video->hatVerlassen( 0 ) && sichtbar )
  397. setSichtbar( 0 );
  398. bool ret = laden->tick( tickVal );
  399. this->tickVal += tickVal * 150;
  400. int val = ( int )this->tickVal;
  401. this->tickVal -= val;
  402. if( val )
  403. {
  404. if( sichtbar && alpha != 255 )
  405. {
  406. if( alpha + val > 255 )
  407. alpha = 255;
  408. else
  409. alpha += (unsigned char)val;
  410. ret = 1;
  411. }
  412. if( !sichtbar && alpha )
  413. {
  414. if( alpha - val < 0 )
  415. alpha = 0;
  416. else
  417. alpha -= (unsigned char)val;
  418. ret = 1;
  419. }
  420. }
  421. return ret;
  422. }
  423. void AHSpielVideo::render( Bild &zRObj )
  424. {
  425. if( !video || !alpha )
  426. return;
  427. if( !zRObj.setDrawOptions( 0, 0, videoF->getBreite() + 10, videoF->getHeight() + 40 ) )
  428. return;
  429. zRObj.setAlpha( alpha );
  430. videoF->render( zRObj );
  431. laden->render( zRObj );
  432. zRObj.releaseAlpha();
  433. zRObj.releaseDrawOptions();
  434. }
  435. // constant
  436. bool AHSpielVideo::istNochSichtbar() const
  437. {
  438. return alpha != 0;
  439. }
  440. // löscht das objekt wenn es nicht mehr gebraucht wird und beendet den Thread
  441. Thread *AHSpielVideo::release()
  442. {
  443. if( ref == 2 && run )
  444. warteAufThread( INFINITE );
  445. return Thread::release();
  446. }
  447. // Inhalt der AHSLETeamListeSpieler Klasse aus AccountHistorie.h
  448. // Konstruktor
  449. AHSLETeamListeSpieler::AHSLETeamListeSpieler( Schrift *zSchrift, char *name, int punkte, char *status, int farbe, int br )
  450. : nameTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, name ) ),
  451. punkteTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Punkte: " ) += punkte ) ),
  452. statusTF( initTextFeld( 215, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, status ) ),
  453. ram( new LRahmen() ),
  454. ref( 1 )
  455. {
  456. TextRenderer tr( zSchrift->getThis() );
  457. tr.setSchriftSize( 12 );
  458. nameTF->setSize( tr.getTextBreite( nameTF->zText()->getText() ) + 5, 20 );
  459. punkteTF->setSize( tr.getTextBreite( punkteTF->zText()->getText() ) + 5, 20 );
  460. statusTF->setSize( tr.getTextBreite( statusTF->zText()->getText() ) + 5, 20 );
  461. if( nameTF->getBreite() > 100 )
  462. punkteTF->setPosition( 10 + nameTF->getBreite(), 0 );
  463. if( punkteTF->getX() + punkteTF->getBreite() > 210 )
  464. statusTF->setPosition( punkteTF->getX() + punkteTF->getBreite() + 5, 0 );
  465. ram->setFarbe( farbe );
  466. ram->setSize( br, 20 );
  467. ram->setRamenBreite( 1 );
  468. }
  469. // Destruktor
  470. AHSLETeamListeSpieler::~AHSLETeamListeSpieler()
  471. {
  472. nameTF->release();
  473. punkteTF->release();
  474. statusTF->release();
  475. ram->release();
  476. }
  477. // nicht constant
  478. void AHSLETeamListeSpieler::render( int yOff, Bild &zRObj )
  479. {
  480. if( !zRObj.setDrawOptions( 2, yOff, ram->getBreite(), ram->getHeight() ) )
  481. return;
  482. nameTF->render( zRObj );
  483. punkteTF->render( zRObj );
  484. statusTF->render( zRObj );
  485. ram->render( zRObj );
  486. zRObj.releaseDrawOptions();
  487. }
  488. // cnstant
  489. // Reference Counting
  490. AHSLETeamListeSpieler *AHSLETeamListeSpieler::getThis()
  491. {
  492. ref++;
  493. return this;
  494. }
  495. AHSLETeamListeSpieler *AHSLETeamListeSpieler::release()
  496. {
  497. ref--;
  498. if( !ref )
  499. delete this;
  500. return 0;
  501. }
  502. // Inhalt der AHSLETeamListeTeam Klasse aus AccountHistorie.h
  503. // Konstruktor
  504. AHSLETeamListeTeam::AHSLETeamListeTeam( Schrift *zSchrift, char *name, int sAnz, char *status, int farbe, int br )
  505. : nameTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, name ) ),
  506. sAnzahlTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Spieleranzahl: " ) += sAnz ) ),
  507. statusTF( initTextFeld( 215, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, status ) ),
  508. ram( new LRahmen() ),
  509. members( new RCArray< AHSLETeamListeSpieler >() ),
  510. ref( 1 )
  511. {
  512. TextRenderer tr( zSchrift->getThis() );
  513. tr.setSchriftSize( 12 );
  514. nameTF->setSize( tr.getTextBreite( nameTF->zText()->getText() ) + 5, 20 );
  515. sAnzahlTF->setSize( tr.getTextBreite( sAnzahlTF->zText()->getText() ) + 5, 20 );
  516. statusTF->setSize( tr.getTextBreite( statusTF->zText()->getText() ) + 5, 20 );
  517. if( nameTF->getBreite() > 100 )
  518. sAnzahlTF->setPosition( 10 + nameTF->getBreite(), 0 );
  519. if( sAnzahlTF->getX() + sAnzahlTF->getBreite() > 210 )
  520. statusTF->setPosition( sAnzahlTF->getX() + sAnzahlTF->getBreite() + 5, 0 );
  521. ram->setFarbe( farbe );
  522. ram->setSize( br, 20 );
  523. ram->setRamenBreite( 1 );
  524. }
  525. // Destruktor
  526. AHSLETeamListeTeam::~AHSLETeamListeTeam()
  527. {
  528. nameTF->release();
  529. sAnzahlTF->release();
  530. statusTF->release();
  531. ram->release();
  532. members->release();
  533. }
  534. // nicht constant
  535. void AHSLETeamListeTeam::addSpieler( AHSLETeamListeSpieler *s )
  536. {
  537. members->add( s );
  538. int maxHö = 20;
  539. int anz = members->getEintragAnzahl();
  540. if( anz )
  541. maxHö += 4 + 20 * anz;
  542. ram->setSize( ram->getBreite(), maxHö );
  543. }
  544. void AHSLETeamListeTeam::render( int xOff, int yOff, Bild &zRObj )
  545. {
  546. if( !zRObj.setDrawOptions( xOff, yOff, ram->getBreite(), ram->getHeight() ) )
  547. return;
  548. nameTF->render( zRObj );
  549. sAnzahlTF->render( zRObj );
  550. statusTF->render( zRObj );
  551. ram->render( zRObj );
  552. yOff = 22;
  553. int anz = members->getEintragAnzahl();
  554. for( int i = 0; i < anz; i++ )
  555. {
  556. members->z( i )->render( yOff, zRObj );
  557. yOff += 20;
  558. }
  559. zRObj.releaseDrawOptions();
  560. }
  561. // constant
  562. int AHSLETeamListeTeam::getHeight() const
  563. {
  564. return ram->getHeight();
  565. }
  566. // Reference Counting
  567. AHSLETeamListeTeam *AHSLETeamListeTeam::getThis()
  568. {
  569. ref++;
  570. return this;
  571. }
  572. AHSLETeamListeTeam *AHSLETeamListeTeam::release()
  573. {
  574. ref--;
  575. if( !ref )
  576. delete this;
  577. return 0;
  578. }
  579. // Inhalt der AHSLETeamListe Klasse aus AccountHistorie.h
  580. // Konstruktor
  581. AHSLETeamListe::AHSLETeamListe( int xPos )
  582. : members( new RCArray< AHSLETeamListeTeam >() ),
  583. xPos( xPos ),
  584. ref( 1 )
  585. {
  586. }
  587. // Destruktor
  588. AHSLETeamListe::~AHSLETeamListe()
  589. {
  590. members->release();
  591. }
  592. // nicht constant
  593. void AHSLETeamListe::addTeam( AHSLETeamListeTeam *t )
  594. {
  595. members->add( t );
  596. }
  597. void AHSLETeamListe::render( Bild &zRObj )
  598. {
  599. int y = 25;
  600. int anz = members->getEintragAnzahl();
  601. for( int i = 0; i < anz; i++ )
  602. {
  603. members->z( i )->render( xPos, y, zRObj );
  604. y += members->z( i )->getHeight();
  605. }
  606. }
  607. // constant
  608. int AHSLETeamListe::getHeight() const
  609. {
  610. int anz = members->getEintragAnzahl();
  611. int hö = 0;
  612. for( int i = 0; i < anz; i++ )
  613. hö += members->z( i )->getHeight();
  614. return hö;
  615. }
  616. int AHSLETeamListe::getBreite() const
  617. {
  618. return 730 - xPos;
  619. }
  620. // Reference Counting
  621. AHSLETeamListe *AHSLETeamListe::getThis()
  622. {
  623. ref++;
  624. return this;
  625. }
  626. AHSLETeamListe *AHSLETeamListe::release()
  627. {
  628. ref--;
  629. if( !ref )
  630. delete this;
  631. return 0;
  632. }
  633. // Inhalt der AHSpielListeEintrag Klasse aus AccountHistorie.h
  634. // Konstruktor
  635. AHSpielListeEintrag::AHSpielListeEintrag( int id, int karteId, Schrift *zSchrift, char *spiel, char *karte, char *datum, char *status,
  636. char *dauer, char *spielStatus, char *gewinner, int sAnzahl )
  637. : spielTF( initTextFeld( 5, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Spiel: " ) += spiel ) ),
  638. karteTF( initTextFeld( 110, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Karte: " ) += karte ) ),
  639. datumTF( initTextFeld( 215, 0, 180, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Datum: " ) += datum ) ),
  640. statusTF( initTextFeld( 400, 0, 100, 20, zSchrift, TextFeld::Style::Text | TextFeld::Style::Center, Text( "Status: " ) += status ) ),
  641. spiel( new Text( spiel ) ),
  642. karte( new Text( karte ) ),
  643. datum( new Text( datum ) ),
  644. status( new Text( status ) ),
  645. detailsK( initKnopf( 715, 0, 20, 20, 0, 0, "" ) ),
  646. dauerTF( initTextFeld( 5, 25, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Dauer: " ) += dauer ) ),
  647. spielStatusTF( initTextFeld( 5, 45, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Status: " ) += spielStatus ) ),
  648. gewinnerTF( initTextFeld( 5, 65, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Gewinner: " ) += gewinner ) ),
  649. sAnzahlTF( initTextFeld( 5, 85, 100, 20, zSchrift, TextFeld::Style::Text, Text( "Spieleranzahl: " ) += sAnzahl ) ),
  650. statistikK( initKnopf( 5, 105, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Statistik" ) ),
  651. videoK( initKnopf( 5, 130, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Aufzeichnung" ) ),
  652. liste( 0 ),
  653. ram( new LRahmen() ),
  654. ausklappen( bilder->get( "data/client/bilder/account.ltdb/ausklappen.png" ) ),
  655. einklappen( bilder->get( "data/client/bilder/account.ltdb/einklappen.png" ) ),
  656. id( id ),
  657. karteId( karteId ),
  658. tickVal( 0 ),
  659. aktion( 0 ),
  660. maxHö( 155 ),
  661. ref( 1 )
  662. {
  663. detailsK->setStyle( Knopf::Style::Sichtbar | Knopf::Style::Erlaubt | Knopf::Style::Hintergrund | Knopf::Style::HAlpha | Knopf::Style::HBild | Knopf::Style::KlickBuffer );
  664. detailsK->setHintergrundBildZ( ausklappen->getThis() );
  665. initToolTip( detailsK, "Details anzeigen.", zSchrift, hauptScreen );
  666. TextRenderer tr( zSchrift->getThis() );
  667. tr.setSchriftSize( 12 );
  668. spielTF->setSize( tr.getTextBreite( spielTF->zText()->getText() ) + 5, 20 );
  669. karteTF->setSize( tr.getTextBreite( karteTF->zText()->getText() ) + 5, 20 );
  670. datumTF->setSize( tr.getTextBreite( datumTF->zText()->getText() ) + 5, 20 );
  671. statusTF->setSize( tr.getTextBreite( statusTF->zText()->getText() ) + 5, 20 );
  672. dauerTF->setSize( tr.getTextBreite( dauerTF->zText()->getText() ), 20 );
  673. spielStatusTF->setSize( tr.getTextBreite( spielStatusTF->zText()->getText() ), 20 );
  674. gewinnerTF->setSize( tr.getTextBreite( gewinnerTF->zText()->getText() ), 20 );
  675. sAnzahlTF->setSize( tr.getTextBreite( sAnzahlTF->zText()->getText() ), 20 );
  676. if( spielTF->getBreite() > 100 )
  677. karteTF->setPosition( 10 + spielTF->getBreite(), 0 );
  678. if( karteTF->getX() + karteTF->getBreite() > 210 )
  679. datumTF->setPosition( karteTF->getX() + karteTF->getBreite() + 5, 0 );
  680. if( datumTF->getX() + datumTF->getBreite() > 395 )
  681. statusTF->setPosition( datumTF->getX() + datumTF->getBreite() + 5, 0 );
  682. ram->setFarbe( 0xFFFFFFFF );
  683. ram->setSize( 735, 20 );
  684. ram->setRamenBreite( 1 );
  685. int br = dauerTF->getBreite();
  686. br = br > spielStatusTF->getBreite() ? br : spielStatusTF->getBreite();
  687. br = br > gewinnerTF->getBreite() ? br : gewinnerTF->getBreite();
  688. br = br > sAnzahlTF->getBreite() ? br : sAnzahlTF->getBreite();
  689. statistikK->setSize( br, statistikK->getHeight() );
  690. videoK->setSize( br, videoK->getHeight() );
  691. liste = new AHSLETeamListe( br + 10 );
  692. }
  693. // Destruktor
  694. AHSpielListeEintrag::~AHSpielListeEintrag()
  695. {
  696. spielTF->release();
  697. karteTF->release();
  698. datumTF->release();
  699. statusTF->release();
  700. spiel->release();
  701. karte->release();
  702. datum->release();
  703. status->release();
  704. detailsK->release();
  705. dauerTF->release();
  706. spielStatusTF->release();
  707. gewinnerTF->release();
  708. sAnzahlTF->release();
  709. statistikK->release();
  710. videoK->release();
  711. liste->release();
  712. ram->release();
  713. einklappen->release();
  714. ausklappen->release();
  715. }
  716. // nicht constant
  717. void AHSpielListeEintrag::addTeam( AHSLETeamListeTeam *t )
  718. {
  719. liste->addTeam( t );
  720. maxHö = liste->getHeight();
  721. maxHö = 155 > maxHö + 30 ? 155 : maxHö + 30;
  722. }
  723. bool AHSpielListeEintrag::tick( double tickVal )
  724. {
  725. bool ret = detailsK->tick( tickVal );
  726. ret |= statistikK->tick( tickVal );
  727. ret |= videoK->tick( tickVal );
  728. this->tickVal += tickVal * 150;
  729. int val = ( int )this->tickVal;
  730. this->tickVal -= val;
  731. if( val )
  732. {
  733. if( detailsK->zHintergrundBild() == ausklappen && ram->getHeight() != 20 )
  734. {
  735. if( ram->getHeight() - val < 20 )
  736. ram->setSize( ram->getBreite(), 20 );
  737. else
  738. ram->setSize( ram->getBreite(), ram->getHeight() - val );
  739. ret = 1;
  740. }
  741. if( detailsK->zHintergrundBild() == einklappen )
  742. {
  743. if( ram->getHeight() > maxHö )
  744. {
  745. if( ram->getHeight() - val < maxHö )
  746. ram->setSize( ram->getBreite(), maxHö );
  747. else
  748. ram->setSize( ram->getBreite(), ram->getHeight() - val );
  749. ret = 1;
  750. }
  751. if( ram->getHeight() < maxHö )
  752. {
  753. if( ram->getHeight() + val > maxHö )
  754. ram->setSize( ram->getBreite(), maxHö );
  755. else
  756. ram->setSize( ram->getBreite(), ram->getHeight() + val );
  757. ret = 1;
  758. }
  759. }
  760. }
  761. return ret;
  762. }
  763. void AHSpielListeEintrag::doMausEreignis( MausEreignis &me )
  764. {
  765. bool meVera = 0;
  766. bool meVeraTmp = 0;
  767. if( me.mx < 0 || me.my < 0 || me.mx >= ram->getBreite() || me.my >= ram->getHeight() )
  768. {
  769. meVeraTmp = me.verarbeitet;
  770. me.verarbeitet = 1;
  771. meVera = 1;
  772. }
  773. int vera = me.verarbeitet;
  774. detailsK->doMausEreignis( me );
  775. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  776. {
  777. if( detailsK->zHintergrundBild() == einklappen )
  778. detailsK->setHintergrundBildZ( ausklappen->getThis() );
  779. else
  780. detailsK->setHintergrundBildZ( einklappen->getThis() );
  781. }
  782. vera = me.verarbeitet;
  783. statistikK->doMausEreignis( me );
  784. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  785. aktion = 1;
  786. vera = me.verarbeitet;
  787. videoK->doMausEreignis( me );
  788. if( !vera && me.verarbeitet && me.id == ME_RLinks )
  789. aktion = 2;
  790. if( meVera )
  791. me.verarbeitet = meVeraTmp;
  792. }
  793. void AHSpielListeEintrag::render( int yOff, Bild &zRObj )
  794. {
  795. if( !zRObj.setDrawOptions( 5, yOff, ram->getBreite(), ram->getHeight() ) )
  796. return;
  797. ram->render( zRObj );
  798. if( ram->getHeight() > 20 )
  799. zRObj.drawLinieH( 1, 20, ram->getBreite() - 2, ram->getFarbe() );
  800. if( !zRObj.setDrawOptions( 1, 1, ram->getBreite() - 2, ram->getHeight() - 2 ) )
  801. {
  802. zRObj.releaseDrawOptions();
  803. return;
  804. }
  805. spielTF->render( zRObj );
  806. karteTF->render( zRObj );
  807. datumTF->render( zRObj );
  808. statusTF->render( zRObj );
  809. detailsK->render( zRObj );
  810. dauerTF->render( zRObj );
  811. spielStatusTF->render( zRObj );
  812. gewinnerTF->render( zRObj );
  813. sAnzahlTF->render( zRObj );
  814. statistikK->render( zRObj );
  815. videoK->render( zRObj );
  816. liste->render( zRObj );
  817. zRObj.releaseDrawOptions();
  818. zRObj.releaseDrawOptions();
  819. }
  820. int AHSpielListeEintrag::getAktion()
  821. {
  822. int ret = aktion;
  823. aktion = 0;
  824. return ret;
  825. }
  826. // constant
  827. int AHSpielListeEintrag::getKarteId() const
  828. {
  829. return karteId;
  830. }
  831. int AHSpielListeEintrag::getHeight() const
  832. {
  833. return ram->getHeight();
  834. }
  835. int AHSpielListeEintrag::getId() const
  836. {
  837. return id;
  838. }
  839. int AHSpielListeEintrag::getListeBreite() const
  840. {
  841. return liste->getBreite();
  842. }
  843. Text *AHSpielListeEintrag::zSpiel() const
  844. {
  845. return spiel;
  846. }
  847. Text *AHSpielListeEintrag::zKarte() const
  848. {
  849. return karte;
  850. }
  851. Text *AHSpielListeEintrag::zDatum() const
  852. {
  853. return datum;
  854. }
  855. Text *AHSpielListeEintrag::zStatus() const
  856. {
  857. return status;
  858. }
  859. // Reference Counting
  860. AHSpielListeEintrag *AHSpielListeEintrag::getThis()
  861. {
  862. ref++;
  863. return this;
  864. }
  865. AHSpielListeEintrag *AHSpielListeEintrag::release()
  866. {
  867. ref--;
  868. if( !ref )
  869. delete this;
  870. return 0;
  871. }
  872. // Inhalt der AHSpielListe Klasse aus AccountHistorie.h
  873. // Konstruktor
  874. AHSpielListe::AHSpielListe()
  875. : Zeichnung(),
  876. ram( new LRahmen() ),
  877. scroll( new VScrollBar() ),
  878. members( new RCArray< AHSpielListeEintrag >() ),
  879. sortSpalte( new Text( "Spiel" ) ),
  880. sortAbsteigend( 0 )
  881. {
  882. pos = Punkt( 10, 40 );
  883. ram->setFarbe( 0xFFFFFFFF );
  884. ram->setRamenBreite( 1 );
  885. ram->setSize( 760, 380 );
  886. scroll->update( 0, 380 );
  887. }
  888. // Destruktor
  889. AHSpielListe::~AHSpielListe()
  890. {
  891. ram->release();
  892. scroll->release();
  893. members->release();
  894. sortSpalte->release();
  895. }
  896. // privat
  897. int AHSpielListe::getReihenfolge( int *arr )
  898. {
  899. lockZeichnung();
  900. int anz = members->getEintragAnzahl();
  901. if( !anz )
  902. {
  903. unlockZeichnung();
  904. return 0;
  905. }
  906. int ret = 0;
  907. bool *fertig = new bool[ anz ];
  908. ZeroMemory( fertig, anz );
  909. for( int i = 0; i < anz; i++ )
  910. {
  911. int index = -1;
  912. Text minMaxT;
  913. Zeit minMaxZ;
  914. for( int j = 0; j < anz; j++ )
  915. {
  916. AHSpielListeEintrag *tmp = members->z( j );
  917. if( sortSpalte->istGleich( "Spiel" ) && !fertig[ j ] && ( index < 0 ||
  918. ( sortAbsteigend && *tmp->zSpiel() > minMaxT ) || ( !sortAbsteigend && *tmp->zSpiel() < minMaxT ) ) )
  919. {
  920. minMaxT = tmp->zSpiel()->getText();
  921. index = j;
  922. }
  923. else if( sortSpalte->istGleich( "Karte" ) && !fertig[ j ] && ( index < 0 ||
  924. ( sortAbsteigend && *tmp->zKarte() > minMaxT ) || ( !sortAbsteigend && *tmp->zKarte() < minMaxT ) ) )
  925. {
  926. minMaxT = tmp->zKarte()->getText();
  927. index = j;
  928. }
  929. else if( sortSpalte->istGleich( "Datum" ) && !fertig[ j ] && ( index < 0 ||
  930. ( sortAbsteigend && minMaxZ.istKleiner( "y-m-d h:i", tmp->zDatum()->getText() ) ) ||
  931. ( !sortAbsteigend && minMaxZ.istLater( "y-m-d h:i", tmp->zDatum()->getText() ) ) ) )
  932. {
  933. minMaxZ.setZeit( "y-m-d h:i", tmp->zDatum()->getText() );
  934. index = j;
  935. }
  936. else if( sortSpalte->istGleich( "Status" ) && !fertig[ j ] && ( index < 0 ||
  937. ( sortAbsteigend && *tmp->zStatus() > minMaxT ) || ( !sortAbsteigend && *tmp->zStatus() < minMaxT ) ) )
  938. {
  939. minMaxT = tmp->zStatus()->getText();
  940. index = j;
  941. }
  942. }
  943. if( index < 0 )
  944. break;
  945. fertig[ index ] = 1;
  946. arr[ ret ] = index;
  947. ret++;
  948. }
  949. delete[] fertig;
  950. unlockZeichnung();
  951. return ret;
  952. }
  953. // nicht constant
  954. void AHSpielListe::setSortSpalte( char *sp )
  955. {
  956. lockZeichnung();
  957. sortSpalte->setText( sp );
  958. unlockZeichnung();
  959. }
  960. void AHSpielListe::setSortRichtung( bool absteigend )
  961. {
  962. sortAbsteigend = absteigend;
  963. }
  964. void AHSpielListe::reset()
  965. {
  966. lockZeichnung();
  967. members->leeren();
  968. unlockZeichnung();
  969. }
  970. void AHSpielListe::addSpiel( AHSpielListeEintrag *s )
  971. {
  972. lockZeichnung();
  973. members->add( s );
  974. unlockZeichnung();
  975. }
  976. bool AHSpielListe::tick( double tickVal )
  977. {
  978. bool ret = scroll->getRend();
  979. lockZeichnung();
  980. int anz = members->getEintragAnzahl();
  981. for( int i = 0; i < anz; i++ )
  982. ret |= members->z( i )->tick( tickVal );
  983. unlockZeichnung();
  984. return ret;
  985. }
  986. void AHSpielListe::doMausEreignis( MausEreignis &me )
  987. {
  988. bool vera = 0;
  989. if( me.mx - pos.x <= 0 || me.mx - pos.x >= ram->getBreite() || me.my - pos.y <= 0 || me.my - pos.y >= ram->getHeight() )
  990. {
  991. vera = 1;
  992. me.verarbeitet = 1;
  993. }
  994. int mx = me.mx, my = me.my;
  995. me.mx -= pos.x;
  996. me.my -= pos.y;
  997. scroll->doMausMessage( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, me );
  998. me.mx -= 5;
  999. me.my -= 5 - scroll->getScroll();
  1000. lockZeichnung();
  1001. int anz = members->getEintragAnzahl();
  1002. int *rf = new int[ anz ];
  1003. int rfAnz = getReihenfolge( rf );
  1004. for( int i = 0; i < rfAnz; i++ )
  1005. {
  1006. members->z( rf[ i ] )->doMausEreignis( me );
  1007. me.my -= members->z( rf[ i ] )->getHeight() + 5;
  1008. }
  1009. delete[] rf;
  1010. unlockZeichnung();
  1011. me.mx = mx, me.my = my;
  1012. if( vera )
  1013. me.verarbeitet = 0;
  1014. }
  1015. void AHSpielListe::render( Bild &zRObj )
  1016. {
  1017. if( !zRObj.setDrawOptions( pos, ram->getSize() ) )
  1018. return;
  1019. ram->render( zRObj );
  1020. scroll->render( ram->getBreite() - 16, 1, 15, ram->getHeight() - 2, zRObj );
  1021. if( !zRObj.setDrawOptions( 1, 1, ram->getBreite() - 15, ram->getHeight() - 2 ) )
  1022. {
  1023. zRObj.releaseDrawOptions();
  1024. return;
  1025. }
  1026. int anzHö = 5;
  1027. lockZeichnung();
  1028. int anz = members->getEintragAnzahl();
  1029. int *rf = new int[ anz ];
  1030. int rfAnz = getReihenfolge( rf );
  1031. for( int i = 0; i < rfAnz; i++ )
  1032. {
  1033. members->z( rf[ i ] )->render( anzHö - scroll->getScroll(), zRObj );
  1034. anzHö += members->z( rf[ i ] )->getHeight() + 5;
  1035. }
  1036. delete[] rf;
  1037. unlockZeichnung();
  1038. scroll->update( anzHö, ram->getHeight() - 2 );
  1039. zRObj.releaseDrawOptions();
  1040. zRObj.releaseDrawOptions();
  1041. }
  1042. // constant
  1043. int AHSpielListe::getAktion( int *spielId, int *karteId ) const
  1044. {
  1045. int anz = members->getEintragAnzahl();
  1046. for( int i = 0; i < anz; i++ )
  1047. {
  1048. int ak = members->z( i )->getAktion();
  1049. if( ak )
  1050. {
  1051. *spielId = members->z( i )->getId();
  1052. *karteId = members->z( i )->getKarteId();
  1053. return ak;
  1054. }
  1055. }
  1056. return 0;
  1057. }
  1058. // Inhalt der AccountHistorie Klasse aus AccountHistorie.h
  1059. // Konstruktor
  1060. AccountHistorie::AccountHistorie( Schrift *zSchrift )
  1061. : Thread(),
  1062. schrift( zSchrift->getThis() ),
  1063. historieF( initFenster( 810, 40, 780, 450, zSchrift, Fenster::Style::Sichtbar | Fenster::Style::Titel | Fenster::Style::TitelBuffered | Fenster::Style::Rahmen | Fenster::Style::Erlaubt, "Historie von " ) ),
  1064. sortSpalte( initAuswahlBox( 10, 10, 150, 20, zSchrift, ABSTYLE, { "Spiel", "Karte", "Datum", "Status" } ) ),
  1065. sortRichtung( initAuswahlBox( 170, 10, 150, 20, zSchrift, ABSTYLE, { "Aufwärts", "Abwärts" } ) ),
  1066. liste( new AHSpielListe() ),
  1067. statistik( new AHSpielStatistik( zSchrift->getThis() ) ),
  1068. video( new AHSpielVideo( zSchrift->getThis() ) ),
  1069. status( 0 ),
  1070. accId( 0 ),
  1071. animation( 0 ),
  1072. alpha( 255 ),
  1073. alpha2( 255 ),
  1074. alpha3( 255 ),
  1075. tickVal( 0 ),
  1076. rend( 0 )
  1077. {
  1078. initToolTip( sortSpalte, "Wähle aus, nach welcher Spalte die\nTabelle sortiert werden soll.", zSchrift, hauptScreen );
  1079. initToolTip( sortRichtung, "Wähle aus, ob Aufwärts oder Abwärts\nsortiert werden soll.", zSchrift, hauptScreen );
  1080. historieF->addMember( liste->getThis() );
  1081. historieF->addMember( sortSpalte->getThis() );
  1082. historieF->addMember( sortRichtung->getThis() );
  1083. historieF->setMausEreignis( _ret1ME );
  1084. }
  1085. // Destruktor
  1086. AccountHistorie::~AccountHistorie()
  1087. {
  1088. schrift->release();
  1089. historieF->release();
  1090. sortSpalte->release();
  1091. sortRichtung->release();
  1092. statistik->release();
  1093. liste->release();
  1094. video->release();
  1095. }
  1096. // nicht constant
  1097. void AccountHistorie::reset()
  1098. {
  1099. liste->reset();
  1100. statistik->reset();
  1101. video->reset();
  1102. }
  1103. void AccountHistorie::ladeStatistik( int accId )
  1104. {
  1105. if( this->accId == accId )
  1106. return;
  1107. this->status = 0;
  1108. if( run )
  1109. {
  1110. warteAufThread( 1000 );
  1111. ende();
  1112. }
  1113. if( ( animation | 0x1 ) == animation )
  1114. {
  1115. animation |= 0x4;
  1116. this->accId = accId;
  1117. this->status = 1;
  1118. return;
  1119. }
  1120. if( this->accId )
  1121. reset();
  1122. this->accId = accId;
  1123. start();
  1124. this->status = 1;
  1125. }
  1126. void AccountHistorie::thread()
  1127. {
  1128. Text *name = infoClient->getSpielerName( accId );
  1129. if( name )
  1130. {
  1131. name->insert( 0, "Historie von " );
  1132. historieF->setTitel( *name );
  1133. name->release();
  1134. }
  1135. Array< KSGClient::SpielHistorieDaten > *daten = infoClient->getSpielHistorieDaten( accId );
  1136. int anz = daten->getEintragAnzahl();
  1137. for( int i = 0; i < anz; i++ )
  1138. {
  1139. KSGClient::SpielHistorieDaten spiel = daten->get( i );
  1140. AHSpielListeEintrag *spielE = new AHSpielListeEintrag( spiel.id, spiel.karteId, schrift, spiel.spiel, spiel.karte,
  1141. spiel.datum, spiel.status, spiel.dauer,
  1142. spiel.spielStatus, spiel.gewinner, spiel.sAnzahl );
  1143. int tAnz = spiel.teams.getEintragAnzahl();
  1144. for( int j = 0; j < tAnz; j++ )
  1145. {
  1146. KSGClient::SpielHistorieTeamDaten team = spiel.teams.get( j );
  1147. AHSLETeamListeTeam *teamE = new AHSLETeamListeTeam( schrift, team.name, team.sAnzahl, team.status,
  1148. team.farbe, spielE->getListeBreite() );
  1149. int sAnz = team.spieler.getEintragAnzahl();
  1150. for( int k = 0; k < sAnz; k++ )
  1151. {
  1152. KSGClient::SpielHistorieSpielerDaten spieler = team.spieler.get( k );
  1153. AHSLETeamListeSpieler *spielerE = new AHSLETeamListeSpieler( schrift, spieler.name, spieler.punkte, spieler.status,
  1154. spieler.farbe, spielE->getListeBreite() - 4 );
  1155. teamE->addSpieler( spielerE );
  1156. }
  1157. spielE->addTeam( teamE );
  1158. }
  1159. liste->addSpiel( spielE );
  1160. }
  1161. daten->release();
  1162. animation &= ~0x4;
  1163. status = 2;
  1164. run = 0;
  1165. }
  1166. void AccountHistorie::setSichtbar( bool sichtbar, bool nachRechts )
  1167. {
  1168. if( sichtbar )
  1169. {
  1170. if( ( animation | 0x1 ) != animation || ( ( nachRechts && ( animation | 0x2 ) != animation ) || !nachRechts && ( animation | 0x2 ) == animation ) )
  1171. {
  1172. if( nachRechts )
  1173. historieF->setPosition( -810, 40 );
  1174. else
  1175. historieF->setPosition( 810, 40 );
  1176. }
  1177. animation |= 0x1;
  1178. }
  1179. else
  1180. animation &= ~0x1;
  1181. if( nachRechts )
  1182. animation |= 0x2;
  1183. else
  1184. animation &= ~0x2;
  1185. }
  1186. bool AccountHistorie::tick( double zeit )
  1187. {
  1188. if( !statistik->istNochSichtbar() && !video->istNochSichtbar() )
  1189. rend |= historieF->tick( zeit );
  1190. rend |= statistik->tick( zeit );
  1191. rend |= video->tick( zeit );
  1192. tickVal += zeit;
  1193. int valA = (int)( tickVal * 150 );
  1194. int valB = (int)( tickVal * 500 );
  1195. tickVal -= valA / 150.0;
  1196. if( valA )
  1197. {
  1198. if( ( animation | 0x8 ) == animation && alpha2 )
  1199. {
  1200. if( alpha2 - valA <= 0 )
  1201. {
  1202. alpha2 = 0;
  1203. statistik->setSichtbar( 1 );
  1204. }
  1205. else
  1206. alpha2 -= valA;
  1207. rend = 1;
  1208. }
  1209. if( ( animation | 0x8 ) != animation && alpha2 != 255 )
  1210. {
  1211. if( alpha2 + valA >= 255 )
  1212. alpha2 = 255;
  1213. else
  1214. alpha2 += valA;
  1215. rend = 1;
  1216. }
  1217. if( ( animation | 0x10 ) == animation && alpha3 )
  1218. {
  1219. if( alpha3 - valA <= 0 )
  1220. {
  1221. alpha3 = 0;
  1222. video->setSichtbar( 1 );
  1223. }
  1224. else
  1225. alpha3 -= valA;
  1226. rend = 1;
  1227. }
  1228. if( ( animation | 0x10 ) != animation && alpha3 != 255 )
  1229. {
  1230. if( alpha3 + valA >= 255 )
  1231. alpha3 = 255;
  1232. else
  1233. alpha3 += valA;
  1234. rend = 1;
  1235. }
  1236. if( ( animation | 0x4 ) == animation && alpha )
  1237. {
  1238. if( alpha - valA <= 0 )
  1239. alpha = 0;
  1240. else
  1241. alpha -= valA;
  1242. rend = 1;
  1243. if( !alpha )
  1244. {
  1245. reset();
  1246. start();
  1247. }
  1248. }
  1249. if( ( animation | 0x4 ) != animation && alpha != 255 )
  1250. {
  1251. if( alpha + valA >= 255 )
  1252. alpha = 255;
  1253. else
  1254. alpha += valA;
  1255. rend = 1;
  1256. }
  1257. }
  1258. if( valB )
  1259. {
  1260. if( ( animation | 0x1 ) == animation )
  1261. { // Sichtbar
  1262. if( ( animation | 0x2 ) == animation )
  1263. { // Nach Rechts
  1264. if( historieF->getX() != 10 )
  1265. {
  1266. if( historieF->getX() + valB > 10 )
  1267. historieF->setPosition( 10, historieF->getY() );
  1268. else
  1269. historieF->setPosition( historieF->getX() + valB, historieF->getY() );
  1270. statistik->setPosition( historieF->getX(), historieF->getY() );
  1271. rend = 1;
  1272. }
  1273. }
  1274. else
  1275. { // Nach Links
  1276. if( historieF->getX() != 10 )
  1277. {
  1278. if( historieF->getX() - valB < 10 )
  1279. historieF->setPosition( 10, historieF->getY() );
  1280. else
  1281. historieF->setPosition( historieF->getX() - valB, historieF->getY() );
  1282. statistik->setPosition( historieF->getX(), historieF->getY() );
  1283. rend = 1;
  1284. }
  1285. }
  1286. }
  1287. else
  1288. { // Unsichtbar
  1289. if( ( animation | 0x2 ) == animation )
  1290. { // Nach Rechts
  1291. if( historieF->getX() != 810 )
  1292. {
  1293. if( historieF->getX() + valB > 810 )
  1294. historieF->setPosition( 810, historieF->getY() );
  1295. else
  1296. historieF->setPosition( historieF->getX() + valB, historieF->getY() );
  1297. statistik->setPosition( historieF->getX(), historieF->getY() );
  1298. rend = 1;
  1299. }
  1300. }
  1301. else
  1302. { // Nach Links
  1303. if( historieF->getX() != -810 )
  1304. {
  1305. if( historieF->getX() - valB < -810 )
  1306. historieF->setPosition( -810, historieF->getY() );
  1307. else
  1308. historieF->setPosition( historieF->getX() - valB, historieF->getY() );
  1309. statistik->setPosition( historieF->getX(), historieF->getY() );
  1310. rend = 1;
  1311. }
  1312. }
  1313. }
  1314. }
  1315. if( !alpha2 && !statistik->istNochSichtbar() )
  1316. {
  1317. animation &= ~0x8;
  1318. statistik->reset();
  1319. }
  1320. if( !alpha3 && !video->istNochSichtbar() )
  1321. {
  1322. animation &= ~0x10;
  1323. video->reset();
  1324. }
  1325. bool ret = rend;
  1326. rend = 0;
  1327. return ret;
  1328. }
  1329. void AccountHistorie::doMausEreignis( MausEreignis &me )
  1330. {
  1331. if( !statistik->istNochSichtbar() && !video->istNochSichtbar() && alpha == 255 && alpha2 == 255 && alpha3 == 255 )
  1332. {
  1333. int sortSpalteS = sortSpalte->getAuswahl();
  1334. int sortRichtungS = sortRichtung->getAuswahl();
  1335. historieF->doMausEreignis( me );
  1336. if( sortSpalte->getAuswahl() != sortSpalteS )
  1337. {
  1338. liste->setSortSpalte( sortSpalte->zEintrag( sortSpalte->getAuswahl() )->zText()->getText() );
  1339. sortSpalte->einklappen();
  1340. }
  1341. if( sortRichtung->getAuswahl() != sortRichtungS )
  1342. {
  1343. liste->setSortRichtung( sortRichtung->getAuswahl() != 0 );
  1344. sortRichtung->einklappen();
  1345. }
  1346. int spielId = 0;
  1347. int karteId = 0;
  1348. int ak = liste->getAktion( &spielId, &karteId );
  1349. if( ak == 1 )
  1350. { // Statistik anzeigen
  1351. if( statistik->ladeDaten( spielId, karteId ) )
  1352. animation |= 0x8;
  1353. }
  1354. if( ak == 2 )
  1355. { // Aufzeichnung abspielen
  1356. if( video->ladeDaten( spielId, karteId ) )
  1357. animation |= 0x10;
  1358. }
  1359. }
  1360. if( statistik->istNochSichtbar() )
  1361. statistik->doMausEreignis( me );
  1362. }
  1363. void AccountHistorie::doTastaturEreignis( TastaturEreignis &te )
  1364. {
  1365. if( statistik->istNochSichtbar() )
  1366. statistik->doTastaturEreignis( te );
  1367. }
  1368. void AccountHistorie::render( Bild &zRObj )
  1369. {
  1370. zRObj.setAlpha( alpha );
  1371. if( alpha2 && alpha3 )
  1372. {
  1373. zRObj.setAlpha( alpha2 );
  1374. zRObj.setAlpha( alpha3 );
  1375. historieF->render( zRObj );
  1376. zRObj.releaseAlpha();
  1377. zRObj.releaseAlpha();
  1378. }
  1379. if( statistik->istNochSichtbar() )
  1380. statistik->render( zRObj );
  1381. if( video->istNochSichtbar() )
  1382. video->render( zRObj );
  1383. zRObj.releaseAlpha();
  1384. }
  1385. // constant
  1386. int AccountHistorie::getStatus() const
  1387. {
  1388. return status;
  1389. }